package com.epay.recharge;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.stylefeng.guns.modular.system.entity.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epay.Epay;
import com.epay.PayUrl;
import com.epay.service.PlatChannelService;
import com.epay.service.PlatMerOrderService;
import com.epay.service.RechargeService;
import com.epay.util.DigestUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import params.PlatMerOrderParam;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import javax.annotation.Resource;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;

@Service("rechargeService")
@Slf4j
public class RechargeServiceImpl implements RechargeService {

    private static final String ALGORITHM = "AES/CBC/PKCS5Padding";

    @Resource
    PlatChannelService platChannelService;

    @Resource
    PlatMerOrderService platMerOrderService;

    public static String java_openssl_encrypt(String data, String password, String iv) throws Exception {
        byte[] key = new byte[32];
        for (int i = 0; i < 32; i++) {
            if (i < password.getBytes().length) {
                key[i] = password.getBytes()[i];
            } else {
                key[i] = 0;
            }
        }
        Cipher cipher = Cipher.getInstance(ALGORITHM);
        cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"), new IvParameterSpec(iv.getBytes()));
        String base64Str = java.util.Base64.getEncoder().encodeToString(cipher.doFinal(data.getBytes()));
        return base64Str;
       /* Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
        SecretKeySpec secretKey = new SecretKeySpec(password.getBytes(StandardCharsets.UTF_8), "AES");
        IvParameterSpec ivParameterSpec = new IvParameterSpec(iv.getBytes(StandardCharsets.UTF_8), 0,
                cipher.getBlockSize());
        cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivParameterSpec);
        byte[] bytes = cipher.doFinal(data.getBytes(StandardCharsets.UTF_8));
        String sign = Base64.getEncoder().encodeToString(bytes);
        return sign;*/
    }

    public static String convertUrlNotEmpty(Map<String, Object> map, String join, String eq) {
        StringBuilder s = new StringBuilder("");
        for (String key : map.keySet()) {
            if (null != map.get(key) && !"".equals(map.get(key))) {
                s.append(key).append(eq).append(map.get(key)).append(join);
            }
        }
        return s.substring(0, s.toString().length() - 1);
    }

    public String convertUrl(Map<String, String> map, String join, String eq) {
        StringBuffer url = new StringBuffer();

        for (String result : map.keySet()) {
            if (!map.containsKey(result) || StringUtils.isEmpty(map.get(result))) {
                continue;
            }
            url.append(result).append(eq).append(map.get(result)).append(join);

        }

        return url.substring(0, url.toString().length() - 1);

    }

    public String convertUrlIsEmpty(Map<String, String> map, String join, String eq) {
        StringBuffer url = new StringBuffer();

        for (String result : map.keySet()) {
            url.append(result).append(eq).append(map.get(result)).append(join);

        }

        return url.substring(0, url.toString().length() - 1);

    }

    public String convertUrlIsEmptyObject(Map<String, Object> map, String join, String eq) {
        StringBuffer url = new StringBuffer();

        for (String result : map.keySet()) {
            url.append(result).append(eq).append(map.get(result)).append(join);

        }

        return url.substring(0, url.toString().length() - 1);

    }

    public String appendValue(Map<String, Object> map) {
        StringBuilder stringBuilder = new StringBuilder("");
        for (Map.Entry<String, Object> m : map.entrySet()) {
            stringBuilder.append(m.getValue());
        }
        return stringBuilder.toString();
    }

    @Override
    public PayUrl kaerPayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        SortedMap sortedMap = new TreeMap();
        sortedMap.put("mchNo", platMer.getMerKey());
        sortedMap.put("mchOrderNo", platMerOrderParam.getOrderId());
        sortedMap.put("productCode", platMerBaseCode.getBaseCode());
        sortedMap.put("orderAmount", platMerOrderParam.getAmount().toString());
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("" +
                "", String.valueOf(System.currentTimeMillis()));


        String s = convertUrl(sortedMap, "&", "=");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        s = s + "&sign=" + sign;
        s = s + "&" + Epay.REAL_URL + "=" + channel.getRealUrl();
        String createUrl = channel.getCreateUrl();

        String body = HttpUtil.createGet(createUrl + "?" + s).execute().body();

        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getInteger("code") == 1) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }


        return new PayUrl(1, channel.getChannelCode(), body, platMerOrderParam.getOrderId(), false, platMerOrderParam.getAmount());

    }

    public PayUrl yfapyUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        return yinFuTongUrl(platMer, platMerBaseCode, platMerOrderParam, channel);

    }

    public PayUrl mdpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        return yinFuTongUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl yinFuTongUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());
        if (channel.getChannelCode().equals("wenxinpay")) {
            sortedMap.put("pay_is_form", "1");
        }
        String s = convertUrl(sortedMap, "&", "=");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        s = s + "&pay_productname=test&pay_md5sign=" + sign;
        String createUrl = channel.getCreateUrl();

        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    @Override
    public PayUrl jinZhiFuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map sortedMap = new LinkedHashMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyyMMddHHmmss"));
        sortedMap.put("pay_channelCode", platMerBaseCode.getBaseCode());
//        sortedMap.put("pay_bankcode", platMerBaseCode.getBankCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
//        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());

        String s = convertUrl(sortedMap, "&", "^");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        log.info("s  {}", s);

        s = convertUrl(sortedMap, "&", "=") + "&pay_md5sign=" + sign;
        String createUrl = channel.getCreateUrl();

        log.info("url {}", createUrl + "?" + s);

        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    @Override
    public PayUrl aqiangUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map sortedMap = new TreeMap();
        sortedMap.put("mch_id", platMer.getMerKey());
        sortedMap.put("child_type", platMerBaseCode.getBaseCode());
        sortedMap.put("out_trade_no", platMerOrderParam.getOrderId());
        sortedMap.put("mch_secret", platMer.getPrivateKey());
        sortedMap.put("pay_type", "PERSONAL_RED_PACK");
        sortedMap.put("total_fee", String.format("%.2f", platMerOrderParam.getAmount()));
        try {
            sortedMap.put("notify_url", URLEncoder.encode(channel.getNotifyUrl(), "utf-8"));
        } catch (Exception ex) {
            log.error(" url encode error {}", channel.getNotifyUrl(), ex);
        }
        sortedMap.put("timestamp", (System.currentTimeMillis() / 1000) + "");

        String s = convertUrl(sortedMap, "&", "=");

        String sign = SecureUtil.md5(s).toUpperCase();
        String createUrl = channel.getCreateUrl();

        log.info("orderId {}", platMerOrderParam.getOrderId());

        sortedMap.remove("mch_secret");
        String body = HttpUtil.createGet(createUrl + "?" + convertUrl(sortedMap, "&", "=") + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a qiang {}", jsonObject.toJSONString());

        if (jsonObject.getBoolean("status") == true && jsonObject.getInteger("code").intValue() == 100) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return null;
    }

    @Override
    public PayUrl tongfuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        Map sortedMap = new TreeMap();
        sortedMap.put("merchant_id", platMer.getMerKey());
        sortedMap.put("order_no", platMerOrderParam.getOrderId());
        sortedMap.put("type", platMerBaseCode.getBaseCode());
        sortedMap.put("amount", String.format("%.2f", platMerOrderParam.getAmount()));
        sortedMap.put("user_identifier", RandomUtil.randomNumbers(10));
        sortedMap.put("callback_url", channel.getNotifyUrl());


        String s = convertUrl(sortedMap, "&", "=");

        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&key=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();
        String createUrl = channel.getCreateUrl();
        s = s + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign;
        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    @Override
    public PayUrl huicaiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        SortedMap sortedMap = new TreeMap();
        sortedMap.put("merchant", platMer.getMerKey());
        sortedMap.put("amount", String.format("%.2f", platMerOrderParam.getAmount()));
        sortedMap.put("paymentType", platMerBaseCode.getBaseCode());
        sortedMap.put("username", RandomUtil.randomNumbers(5));
        sortedMap.put("callback", channel.getNotifyUrl());
        sortedMap.put("remark", "recharge");
        sortedMap.put("paymentReference", platMerOrderParam.getOrderId());
        sortedMap.put("clientIp", "");


        String s = convertUrlIsEmpty(sortedMap, "&", "=");

        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&key=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        s = s + "&sign=" + sign;
        s = s + "&" + Epay.REAL_URL + "=" + channel.getRealUrl();
        String createUrl = channel.getCreateUrl();

        String body = HttpUtil.createGet(createUrl + "?" + s).execute().body();

        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getBoolean("success") == true) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("redirect"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }


        return new PayUrl(1, channel.getChannelCode(), body, platMerOrderParam.getOrderId(), false, platMerOrderParam.getAmount());

    }

    @Override
    public PayUrl mumuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map signData = new LinkedHashMap();
        signData.put("c_code", platMer.getMerKey());

        signData.put("pay_type", platMerBaseCode.getBaseCode());
        signData.put("pay_amt", String.format("%.2f", platMerOrderParam.getAmount()));
        signData.put("agent_bill_id", platMerOrderParam.getOrderId());


        String s = convertUrl(signData, "&", "=");

        Map sortedMap = new LinkedHashMap();
        sortedMap.put("c_code", platMer.getMerKey());
        sortedMap.put("pay_amt", String.format("%.2f", platMerOrderParam.getAmount()));
        sortedMap.put("pay_type", platMerBaseCode.getBaseCode());
        sortedMap.put("goods_name", "good");
        sortedMap.put("remark", "remark");
        sortedMap.put("agent_bill_id", platMerOrderParam.getOrderId());
        sortedMap.put("notify_url", channel.getNotifyUrl());
        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&key=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toLowerCase();
        String createUrl = channel.getCreateUrl();
        String body = HttpUtil.createGet(createUrl + "?" + convertUrl(sortedMap, "&", "=") + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a qiang {}", jsonObject.toJSONString());

        if (jsonObject.getInteger("res") == 0) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return null;
    }

    @Override
    public PayUrl rutongUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        SortedMap sortedMap = new TreeMap();
//        sortedMap.put("orgId", platMer.getMerKey());
        sortedMap.put("tradeNo", platMerOrderParam.getOrderId());
        sortedMap.put("channelNo", platMerBaseCode.getBaseCode());

        sortedMap.put("orderAmount", String.valueOf((platMerOrderParam.getAmount().multiply(new BigDecimal(100)).intValue())));
        sortedMap.put("syncAddr", channel.getNotifyUrl());
        sortedMap.put("asyncAddr", channel.getNotifyUrl());

        sortedMap.put("ipAddr", "127.0.0.1");


        String s = convertUrlIsEmpty(sortedMap, "&", "=");
//        sortedMap.put("extend", "test");
        log.info("recharge url {}", s);

//        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();


        String requestBody = "bizData=" + Base64.encodeBase64String(JSONObject.toJSONBytes(sortedMap)) + "&orgId=" + platMer.getMerKey() + "&txnType=order";

        String sign = requestBody + "&key=" + platMer.getPrivateKey();
        log.info("recharge url  md5 data {}", sign);

        String createUrl = channel.getCreateUrl();

        String body = HttpUtil.createGet(createUrl + "?" + requestBody + "&sign=" + SecureUtil.md5(sign).toUpperCase() + "&" + Epay.REAL_URL + "=" + channel.getRealUrl()).execute().body();

        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a qiang {}", jsonObject.toJSONString());
        return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

    }

    @Override
    public PayUrl tbdfh5Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map signData = new TreeMap();
        signData.put("appid", platMer.getMerKey());
        signData.put("order_no", platMerOrderParam.getOrderId());
        signData.put("amount", String.valueOf((platMerOrderParam.getAmount().multiply(new BigDecimal(100)).intValue())));
        signData.put("product_name", "good");
        signData.put("bank_code", platMerBaseCode.getBaseCode());
        signData.put("notify_url", channel.getNotifyUrl());
        signData.put("return_url", channel.getNotifyUrl());


        String s = convertUrlIsEmpty(signData, "&", "=");

        signData.put("openid", "");
        signData.put("attach", "");
        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "" +
                "&secret=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&secret=" + platMer.getPrivateKey()).toLowerCase();
        String createUrl = channel.getCreateUrl();
        String body = HttpUtil.createGet(createUrl + "?" + convertUrl(signData, "&", "=") + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a qiang {}", jsonObject.toJSONString());

        if (jsonObject.getInteger("status") == 1) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("redirect_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return null;
    }

    @Override
    public PayUrl tbdfUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map signData = new TreeMap();
        signData.put("appid", platMer.getMerKey());
        signData.put("order_no", platMerOrderParam.getOrderId());
        signData.put("amount", String.valueOf((platMerOrderParam.getAmount().multiply(new BigDecimal(100)).intValue())));
        signData.put("product_name", "good");
        signData.put("bank_code", platMerBaseCode.getBaseCode());
        signData.put("notify_url", channel.getNotifyUrl());
        signData.put("return_url", channel.getNotifyUrl());


        String s = convertUrlIsEmpty(signData, "&", "=");

        signData.put("openid", "");
        signData.put("attach", "");
        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&secret=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&secret=" + platMer.getPrivateKey()).toLowerCase();
        String createUrl = channel.getCreateUrl();
        String body = HttpUtil.createGet(createUrl + "?" + convertUrl(signData, "&", "=") + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a qiang {}", jsonObject.toJSONString());

        if (jsonObject.getInteger("status") == 1) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("redirect_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return null;
    }

    @Override
    public PayUrl thepayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map signData = new LinkedHashMap();
        signData.put("memberid", platMer.getMerKey());
        signData.put("orderid", platMerOrderParam.getOrderId());
        signData.put("paytype", platMerBaseCode.getBaseCode());
        signData.put("money", String.format("%.2f", platMerOrderParam.getAmount()));

        signData.put("callurl", channel.getNotifyUrl());


        String s = convertUrlIsEmpty(signData, "&", "=");


        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&secret=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + platMer.getPrivateKey()).toLowerCase();
        String createUrl = channel.getCreateUrl();
        log.info("result a qiang {}", s);
        s = s + "&sign=" + sign;
        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }


    @Override
    public PayUrl aopayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        Map signData = new LinkedHashMap();
        signData.put("ip", "127.0.0.1");

        signData.put("merchantNo", platMer.getMerKey());
        signData.put("money", String.format("%.2f", platMerOrderParam.getAmount()));
        signData.put("notify", channel.getNotifyUrl());
        signData.put("out_trade_no", platMerOrderParam.getOrderId());
        signData.put("pay", platMerBaseCode.getBaseCode());


        String s = convertUrlIsEmpty(signData, "&", "=");
        String sign = SecureUtil.md5(s + "&secret=" + platMer.getPrivateKey()).toUpperCase();

        log.info("map {}", signData);

        String createUrl =  channel.getCreateUrl() + "?" + convertUrl(signData, "&", "=") + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign;
        log.info("url {}", createUrl);
        String body = HttpUtil.createGet(createUrl).execute().body();

        JSONObject jsonObject = JSONObject.parseObject(body);
        log.error(" response ao pay {}", jsonObject.toJSONString());
        if (jsonObject.getInteger("code").intValue() == 200) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return null;
    }


    @Override
    public PayUrl aapayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        Map signData = new TreeMap();
        signData.put("channel", platMerBaseCode.getBaseCode());
        signData.put("mId", platMer.getMerKey());
        signData.put("mOrderNo", platMerOrderParam.getOrderId());
        signData.put("notifyUrl", channel.getNotifyUrl());
        signData.put("price", String.valueOf((platMerOrderParam.getAmount().multiply(new BigDecimal(100)).intValue())));

        String s = convertUrlIsEmpty(signData, "&", "=");


        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&key=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toLowerCase();
        String createUrl = channel.getCreateUrl();
        String body = HttpUtil.createGet(createUrl + "?" + convertUrl(signData, "&", "=") + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a qiang {}", jsonObject.toJSONString());

        if (jsonObject.getInteger("code") == 200) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return null;
    }

    @Override
    public PayUrl binliUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map signData = new TreeMap();
        signData.put("pay_memberid", platMer.getMerKey());
        signData.put("pay_orderid", platMerOrderParam.getOrderId());

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


        signData.put("pay_applydate", simpleDateFormat.format(new Date()));
        signData.put("pay_bankcode", platMerBaseCode.getBaseCode());
        signData.put("pay_notifyurl", channel.getNotifyUrl());
        signData.put("pay_callbackurl", channel.getNotifyUrl());
        signData.put("pay_amount", platMerOrderParam.getAmount().doubleValue() + "");
        String s = convertUrlIsEmpty(signData, "&", "=");


        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&key=" + platMer.getPrivateKey());

        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();
//        signData.put("pay_productname","goods");
        String createUrl = channel.getCreateUrl();

        String url = createUrl + "?" + s + "&pay_productname=good&pay_md5sign=" + sign + "&" + Epay.REAL_URL + "=" + channel.getRealUrl();
        log.info("url {}", url);

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());


    }

    @Override
    public PayUrl mingdongUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return null;
    }

    public PayUrl mingdongzfUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        String createUrl = channel.getCreateUrl();
        String realUrl = channel.getRealUrl();
        String tokenUrl = createUrl + "/commonCremchOrderNoate?" + Epay.REAL_URL +
                "=" + realUrl + "/api/login&app_id=" + platMer.getMerKey() + "&app_key=" + platMer.getPublicKey();
        log.info("token url {}", tokenUrl);

        String body = HttpUtil.createGet(tokenUrl).execute().body();
        log.info("body {}", body);

        JSONObject jsonObject = JSONObject.parseObject(body);

        log.info(" api token result {}", jsonObject);
        if (jsonObject.getInteger("code").intValue() != 200) {

            log.error(" create error");
            return null;
        }

        String token = jsonObject.getJSONObject("data").getString("token");
        Map signData = new TreeMap();
        signData.put("app_id", platMer.getPrivateKey());
        signData.put("pay_type", platMerBaseCode.getBaseCode());
        signData.put("amount", String.format("%.2f", platMerOrderParam.getAmount()));
        signData.put("callback_link", "http://www.baidu.com");
        signData.put("notify_link", channel.getNotifyUrl());
        signData.put("order_sn", platMerOrderParam.getOrderId());


        String s = convertUrlIsEmpty(signData, "&", "=");
        signData.put("token", token);
        String formUrl = createUrl + "/mingdong.html";


        String sign = SecureUtil.md5(s + "&key=" + platMer.getPublicKey()).toUpperCase();
        return new PayUrl(1, channel.getChannelCode(), formUrl + "?" + convertUrlIsEmpty(signData, "&", "=") + "&sign=" + sign, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    @Override
    public PayUrl bajieUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        Map signData = new TreeMap();
        signData.put("app_id", platMer.getMerKey());
        signData.put("order_id", platMerOrderParam.getOrderId());
        signData.put("describe", "good");
        signData.put("total_fee", String.format("%.2f", platMerOrderParam.getAmount()));
        signData.put("notify_url", channel.getNotifyUrl());
        signData.put("return_url", "http://www.baidu.com");
        signData.put("pay_mode", platMerBaseCode.getBaseCode());
        signData.put("client_ip", "127.0.0.1");

        String s = convertUrlIsEmpty(signData, "&", "=");

        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        String createUrl = channel.getCreateUrl();
        String body = HttpUtil.createGet(createUrl + "?" + convertUrl(signData, "&", "=") + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a bajie {}", jsonObject.toJSONString());

        if (jsonObject.getInteger("status").intValue() == 1) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }


        return null;
    }

    @Override
    public PayUrl NEWSPUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        Map signData = new TreeMap();
        signData.put("merchantNo", platMer.getMerKey());
        signData.put("out_trade_no", platMerOrderParam.getOrderId());
        signData.put("money", String.format("%.2f", platMerOrderParam.getAmount()));
        signData.put("notify", channel.getNotifyUrl());
        signData.put("pay", platMerBaseCode.getBaseCode());
        signData.put("ip", "127.0.0.1");


        String s = convertUrlIsEmpty(signData, "&", "=");


        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&secret=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&secret=" + platMer.getPrivateKey()).toUpperCase();
        String createUrl = channel.getCreateUrl();
        String body = HttpUtil.createGet(createUrl + "?" + convertUrl(signData, "&", "=") + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a qiang {}", jsonObject.toJSONString());

        if (jsonObject.getInteger("code").intValue() == 200) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return null;
    }

    @Override
    public PayUrl jufuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        if (platMerOrderParam.getAmount().intValue() < platMerOrderParam.getAmount().doubleValue()) {
            log.error(" amount is must int jufu {}", platMerOrderParam.toString());
        }
        Map signData = new TreeMap();
        signData.put("appId", platMer.getMerKey());
        signData.put("outOrderNo", platMerOrderParam.getOrderId());
        signData.put("nonceStr", RandomUtil.randomNumbers(10) + "");
        signData.put("amount", platMerOrderParam.getAmount().intValue() + "");
        signData.put("orderDesc", "buy order");
        signData.put("notifyUrl", channel.getNotifyUrl());
        signData.put("returnUrl", "http://www.baidu.com");
        signData.put("payType", platMerBaseCode.getBaseCode());
        signData.put("userUnqueNo", RandomUtil.randomNumbers(10) + "");
        signData.put("attach", "test88");
        signData.put("timestamp", (System.currentTimeMillis()) + "");
        String s = "?amount=" + platMerOrderParam.getAmount().intValue() + "" + "&attach=test88&outOrderNo=" + platMerOrderParam.getOrderId() + "&payType=" + platMerBaseCode.getBaseCode() + "" + signData.get("appId") + "" + signData.get("timestamp") + "" + signData.get("nonceStr");
        log.error("sign url  md5" + s);
        s = SecureUtil.md5(s).toLowerCase() + platMer.getPrivateKey();
        s = SecureUtil.md5(s).toUpperCase();
        log.error("sign url  md5" + s);
        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s);


        String body = HttpUtil.createGet(channel.getCreateUrl() + "?" + convertUrlIsEmpty(signData, "&", "=") + "&signature=" + s + "&" + Epay.REAL_URL + "=" + channel.getRealUrl()).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a qiang {}", jsonObject.toJSONString());
        if (jsonObject.getInteger("code").intValue() == 1) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return null;
    }


    @Override
    public PayUrl jinairUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        Map signData = new LinkedHashMap();
        signData.put("ip", "127.0.0.1");

        signData.put("merchantNo", platMer.getMerKey());
        signData.put("money", String.format("%.2f", platMerOrderParam.getAmount()));
        signData.put("notify", channel.getNotifyUrl());
        signData.put("out_trade_no", platMerOrderParam.getOrderId());
        signData.put("pay", platMerBaseCode.getBaseCode());


        String s = convertUrlIsEmpty(signData, "&", "=");
        String sign = SecureUtil.md5(s + "&secret=" + platMer.getPrivateKey()).toUpperCase();

        String createUrl = channel.getCreateUrl();
        String body = HttpUtil.createGet(createUrl + "?" + convertUrl(signData, "&", "=") + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign).execute().body();

        JSONObject jsonObject = JSONObject.parseObject(body);
        log.error(" response ao pay {}", jsonObject.toJSONString());
        if (jsonObject.getInteger("code").intValue() == 200) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return null;
    }

    @Override
    public PayUrl taohaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map signData = new TreeMap();
        signData.put("shopAccountId", platMer.getMerKey());
        signData.put("shopUserId", RandomUtil.randomNumbers(10));
        signData.put("amountInString", String.format("%.2f", platMerOrderParam.getAmount()));
        signData.put("shopNo", platMerOrderParam.getOrderId());
        signData.put("shopCallbackUrl", channel.getNotifyUrl());
        signData.put("returnUrl", "http://www.baidu.com");
        signData.put("target", "3");
        signData.put("payChannel", platMerBaseCode.getBaseCode());
        signData.put("apiVersion", "2");


        String requestData = signData.get("shopAccountId") + "&" + signData.get("shopUserId") + "&" + signData.get("amountInString") + "&" + signData.get("shopNo") + "&" + signData.get("payChannel") + "&" + platMer.getPrivateKey();
        log.error("sign url  md5" + requestData);
        String sign = SecureUtil.md5(requestData).toLowerCase();


        String body = HttpUtil.createGet(channel.getCreateUrl() + "?" + convertUrlIsEmpty(signData, "&", "=") + "&sign=" + sign + "&" + Epay.REAL_URL + "=" + channel.getRealUrl()).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", jsonObject.toJSONString());
        if (jsonObject.getInteger("code").intValue() == 0) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("page_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return null;
    }

    @Override
    public PayUrl sanfangUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
//        String token = "http://gd.china-ni.cn/gateway/api/trade";

        SortedMap<String, Object> params = new TreeMap<String, Object>();
        params.put("tradeType", "cs.pay.submit");
        params.put("version", "2.0");
        params.put("channel", platMerBaseCode.getBaseCode());
        params.put("mchNo", platMer.getMerKey());
        params.put("mchOrderNo", platMerOrderParam.getOrderId());
        params.put("body", "test");
        params.put("amount", (platMerOrderParam.getAmount().intValue()*100)+"");
        params.put("currency", "CNY");
        params.put("timePaid", DateUtil.format(new Date(), "yyyyMMddHHmmss"));
        params.put("remark", "test");

        SortedMap<String, Object> payExtra = new TreeMap<String, Object>();
        payExtra.put("notifyUrl", channel.getNotifyUrl());
        payExtra.put("callbackUrl", "http://www.baidu.com");
        payExtra.put("openId", "TEST165453");
        payExtra.put("appId", "TEST165453".trim());
        payExtra.put("mchCreateIp",  platMerOrderParam.getClientIp().split(",")[0].trim());
       
    //    payExtra.put("clientIp", platMerOrderParam.getClientIp());

        // payExtra.put("mchCreateIp",  platMerOrderParam.getClientIp());
        // payExtra.put("clientIp",  platMerOrderParam.getClientIp());
        params.put("notifyUrl", channel.getNotifyUrl());
        params.put("callbackUrl", "http://www.baidu.com");
        params.put("openId", "TEST165453");
        params.put("appId", "TEST165453");
        params.put("mchCreateIp",   platMerOrderParam.getClientIp().split(",")[0].trim());
        
        params.put("openId", "TEST165453");
        params.put("appId", "TEST165453");
        log.info("sanfang launch map " + params);
        String s = convertUrlNotEmpty(params, "&", "=");
        s += "&paySecret=" +  platMer.getPrivateKey();
        log.info("sanfang launch s " + s);
        // String sign = getSign(params, platMer.getPrivateKey());

        String sign = SecureUtil.md5(s).toUpperCase();
        params.put("sign", sign);
        params.put("extra", JSONObject.toJSONString(payExtra));
        params.remove("openId");
        params.remove("appId");
        params.remove("callbackUrl");
        params.remove("mchCreateIp");

        params.remove("notifyUrl");
        // params.put(Epay.REAL_URL, channel.getRealUrl());

        log.error("sanfang {}", JSON.toJSONString(params));
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(params).execute().body();
        log.info("sanfang result a taobaourl {}", body);
        Map<String, Object> map = JSONObject.parseObject(body);
        if (map != null && map.size() > 0) {
            if ((int) map.get("status") != 0) {

                return null;
            }
            if ((int) map.get("resultCode") == 0) {
                //商户在此处处理业务\

                return new PayUrl(1, channel.getChannelCode(), channel.getRealUrl() + "/token?token=" + map.get("tokenId"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
            }
        }
        return null;
    }

    /**
     * 获取参数签名
     *
     * @param paramMap  签名参数
     * @param paySecret 签名密钥
     * @return
     */
    public static String getSign(Map<String, Object> paramMap, String paySecret) {
        Map<String, Object> map = new TreeMap<String, Object>();
        for (String key : paramMap.keySet()) {
            if ("extra".equals(key)) {
                Map<String, String> payExtra = JSON.parseObject(paramMap.get(key).toString(), Map.class);
                for (String s : payExtra.keySet()) {
                    map.put(s, payExtra.get(s));
                }
            } else {
                map.put(key, paramMap.get(key));
            }
        }
        String s = convertUrlNotEmpty(map, "&", "=");
        s += "&paySecret=" + paySecret;
        log.info("sanfang launch s " + s);
        return SecureUtil.md5(s).toUpperCase();
    }

    /**
     * 获取参数拼接串
     *
     * @param paramMap
     * @return
     */
    public static String getParamStr(Map<String, Object> paramMap) {
        SortedMap<String, Object> smap = new TreeMap<String, Object>(paramMap);
        StringBuffer stringBuffer = new StringBuffer();
        for (Map.Entry<String, Object> m : smap.entrySet()) {
            Object value = m.getValue();
            if (value != null && org.apache.commons.lang3.StringUtils.isNotBlank(String.valueOf(value))) {
                stringBuffer.append(m.getKey()).append("=").append(value).append("&");
            }
        }
        stringBuffer.delete(stringBuffer.length() - 1, stringBuffer.length());

        return stringBuffer.toString();
    }


    /**
     * 验证商户签名
     *
     * @param paramMap  签名参数
     * @param paySecret 签名私钥
     * @param signStr   原始签名密文
     * @return
     */
    public static boolean isRightSign(Map<String, Object> paramMap, String paySecret, String signStr) {

        if (org.apache.commons.lang3.StringUtils.isBlank(signStr)) {
            return false;
        }

        String sign = getSign(paramMap, paySecret);
        if (signStr.equals(sign)) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public PayUrl jinfuhuiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map signData = new TreeMap();
        signData.put("version", "1.0");
        signData.put("customerid", platMer.getMerKey());
        signData.put("sdorderno", platMerOrderParam.getOrderId());
        signData.put("total_fee", String.format("%.2f", platMerOrderParam.getAmount()));
        signData.put("notifyurl", channel.getNotifyUrl());
        signData.put("returnurl", "http://www.baidu.com");
        signData.put("paytype", platMerBaseCode.getBaseCode());

        String s = "version=" + signData.get("version") + "&customerid=" + signData.get("customerid") + "&total_fee=" + signData.get("total_fee") + "&sdorderno=" + signData.get("sdorderno") + "&notifyurl=" + signData.get("notifyurl") + "&returnurl=" + signData.get("returnurl") + "&" + platMer.getPrivateKey();
        signData.put(Epay.REAL_URL, channel.getRealUrl());
        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmpty(signData, "&", "=") + "&sign=" + SecureUtil.md5(s) + "&" + Epay.REAL_URL + "=" + channel.getRealUrl(), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    @Override
    public PayUrl otcUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("merchant", platMer.getMerKey());
        sortedMap.put("orderid", platMerOrderParam.getOrderId());
//        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("paytype", platMerBaseCode.getBaseCode());
        sortedMap.put("callback", channel.getNotifyUrl());
        sortedMap.put("extend", "success");
        sortedMap.put("amount", String.format("%.2f", platMerOrderParam.getAmount()));

        String s = convertUrl(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        log.error("otc  {}", s);
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", SecureUtil.md5(s).toLowerCase());
        String createUrl = channel.getCreateUrl();
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getInteger("code").intValue() == 0) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + convertUrl(sortedMap, "&", "=") + "&sign=" + SecureUtil.md5(s).toLowerCase() + "&" + Epay.REAL_URL + "=" + channel.getRealUrl(), platMerOrderParam.getOrderId() + "&sign=" + SecureUtil.md5(s), true, platMerOrderParam.getAmount());
    }

    @Override
    public PayUrl qianbaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("parter", platMer.getMerKey());
        sortedMap.put("orderid", platMerOrderParam.getOrderId());
        sortedMap.put("type", platMerBaseCode.getBaseCode());
        sortedMap.put("hrefbackurl", channel.getNotifyUrl());
        sortedMap.put("callbackurl", channel.getNotifyUrl());
        sortedMap.put("value", String.format("%.2f", platMerOrderParam.getAmount()));
        String s = "parter=" + platMer.getMerKey() + "&type=" + platMerBaseCode.getBaseCode() + "&value=" + String.format("%.2f", platMerOrderParam.getAmount()) + "&orderid=" + platMerOrderParam.getOrderId() + "&callbackurl=" + channel.getNotifyUrl() + platMer.getPrivateKey();
        log.info("result a qbf {}", s);
        String sign = SecureUtil.md5(s).toLowerCase();

        String createUrl = channel.getCreateUrl();
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("url {}", createUrl + "?" + convertUrl(sortedMap, "&", "=") + "&sign=" + sign);

        log.info("success");
        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + convertUrl(sortedMap, "&", "=") + "&sign=" + sign, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }


    @Override
    public PayUrl pfpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new LinkedHashMap();
        sortedMap.put("fxid", platMer.getMerKey());
        sortedMap.put("fxddh", platMerOrderParam.getOrderId());
        sortedMap.put("fxdesc", "test");
        sortedMap.put("fxfee", String.format("%.2f", platMerOrderParam.getAmount()));
        sortedMap.put("fxattch", "test");
        sortedMap.put("fxip", "127.0.0.1");
        sortedMap.put("fxpay", platMerBaseCode.getBaseCode());
//        sortedMap.put("pay_bankcode", platMerBaseCode.getBankCode());
        sortedMap.put("fxnotifyurl", channel.getNotifyUrl());
        sortedMap.put("fxbackurl", "http://www.baidu.com");
//        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        String s = sortedMap.get("fxid").toString() + sortedMap.get("fxddh").toString() + sortedMap.get("fxfee").toString() + sortedMap.get("fxnotifyurl").toString() + platMer.getPrivateKey();
        log.info("result a qbf {}", s);
        String sign = SecureUtil.md5(s).toLowerCase();


        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("fxsign", sign);
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        String createUrl = channel.getCreateUrl();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getInteger("status").intValue() == 1) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return null;
    }

    @Override
    public PayUrl tianxieUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());

        String s = convertUrl(sortedMap, "&", "=");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        s = s + "&pay_productname=test&pay_md5sign=" + sign;
        String createUrl = channel.getCreateUrl();
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("pay_md5sign", sign);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getInteger("code").intValue() == 1) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());


    }

    public PayUrl yishengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("mch_id", platMer.getMerKey());
        sortedMap.put("ptype", platMerBaseCode.getBaseCode());
        sortedMap.put("order_sn", platMerOrderParam.getOrderId());
        sortedMap.put("money", String.format("%.2f", platMerOrderParam.getAmount()));
        sortedMap.put("goods_desc", "good");
        sortedMap.put("client_ip", "127.0.0.1");
        sortedMap.put("format", "json");
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("time", (System.currentTimeMillis() / 1000) + "");


        String s = convertUrlIsEmptyObject(sortedMap, "&", "=");


        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&key=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toLowerCase();

        sortedMap.put("sign", sign);


        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(sortedMap, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

    }

    public PayUrl shrpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        return dongyaYihaoPayUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl yunpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());

        String s = convertUrl(sortedMap, "&", "=");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        s = s + "&pay_productname=test&pay_md5sign=" + sign;
        String createUrl = channel.getCreateUrl();
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("pay_md5sign", sign);
        sortedMap.put("format", "json");

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a yunpayUrl {}", body);
        if (jsonObject.getString("returncode").equals("00")) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());


    }

    @Override
    public PayUrl dongyaYihaoPayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("mch_id", platMer.getMerKey());
        sortedMap.put("ptype", platMerBaseCode.getBaseCode());
        sortedMap.put("order_sn", platMerOrderParam.getOrderId());
        sortedMap.put("money", String.format("%.2f", platMerOrderParam.getAmount()));
        sortedMap.put("goods_desc", "good");
        sortedMap.put("client_ip", "127.0.0.1");
        sortedMap.put("format", "json");
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("time", (System.currentTimeMillis() / 1000) + "");


        String s = convertUrlIsEmptyObject(sortedMap, "&", "=");


        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&key=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toLowerCase();

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getInteger("code").intValue() == 1) {


            return new PayUrl(1, channel.getChannelCode(), channel.getRealUrl() + "&a=info&osn=" + jsonObject.getJSONObject("data").getString("order_sn"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return null;
    }

    @Override
    public PayUrl dongyatingUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        return yinFuTongUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }


    public PayUrl yooopayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        return yinFuTongUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl hfpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        return yinFuTongUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl huitiaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        return yinFuTongUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl wenxinpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        return yinFuTongUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    @Override
    public PayUrl baolaiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String, String> sortedMap = new TreeMap<>();
        sortedMap.put("mc", platMer.getMerKey());
        sortedMap.put("uid", RandomUtil.randomString(10));
        sortedMap.put("tid", platMerOrderParam.getOrderId());
        sortedMap.put("pt", platMerBaseCode.getBaseCode());
        sortedMap.put("amount", String.format("%.2f", platMerOrderParam.getAmount()));
        sortedMap.put("time", (System.currentTimeMillis() / 1000) + "");
        sortedMap.put("return", "http://www.baidu.com");
        sortedMap.put("notify_url", channel.getNotifyUrl());

        String requestUrl = platMer.getPrivateKey() + sortedMap.get("tid").toString() + sortedMap.get("time").toString() + sortedMap.get("uid").toString() + sortedMap.get("amount");


        log.info("recharge url {}", requestUrl);
        log.info("recharge url  md5 data {}", requestUrl + "&key=" + platMer.getPrivateKey());


        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrl(sortedMap, "&", "=") + "&sign=" + SecureUtil.md5(requestUrl).toLowerCase() + "&" + Epay.REAL_URL + "=" + channel.getRealUrl(), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    /**
     * jyh
     *
     * @param platMer
     * @param platMerBaseCode
     * @param platMerOrderParam
     * @param channel
     * @return
     */
    public PayUrl xiaoshi003Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new LinkedHashMap<>();
        sortedMap.put("api_order_sn", platMerOrderParam.getOrderId());
        sortedMap.put("client_id", platMer.getMerKey());
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("timestamp", System.currentTimeMillis());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("total", decimalFormat.format(platMerOrderParam.getAmount()));
        sortedMap.put("type", platMerBaseCode.getBaseCode());
        log.info("sorteMap " + sortedMap);

        String s = platMer.getPrivateKey() + xiaoshi003Str(sortedMap).toString() + platMer.getPrivateKey();
        String md5Str = SecureUtil.md5(s).toUpperCase();
        log.info("xiaoshi003 s " + s);
        log.info("xiaoshi003 md5 str " + md5Str);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", md5Str);
        log.info("sortedMap " + sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();

        log.info(" body info data xiaoshi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getInteger("status").intValue() == 1) {
            log.info("xiaoshi003 success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("qr_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("xiaoshi003 return null");
        return null;
    }

    public StringBuilder xiaoshi003Str(Map<String, Object> map) {
        StringBuilder stringBuilder = new StringBuilder();
        for (String key : map.keySet()) {
            stringBuilder.append(key).append(map.get(key));
        }
        return stringBuilder;
    }

    /**
     * jyh
     *
     * @param platMer
     * @param platMerBaseCode
     * @param platMerOrderParam
     * @param channel
     * @return
     */
    public PayUrl yjapyUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        return pilinUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl pilinUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("appid", platMer.getMerKey());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("callback_url", channel.getNotifyUrl());
        map.put("success_url", channel.getNotifyUrl());
        map.put("error_url", channel.getNotifyUrl());
        map.put("out_uid", "15017399440");
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("version", "v2.0");
        log.info(" pilin map " + map);

        StringBuilder s = new StringBuilder("");
        for (String key : map.keySet()) {
            if (null != map.get(key) && !"".equals(map.get(key))) {
                s.append(key).append("=").append(map.get(key)).append("&");
            }
        }
        s.append("key").append("=").append(platMer.getPrivateKey());
        log.info("pilin s " + s);

        String md5Str = SecureUtil.md5(s.toString()).toUpperCase();
        log.info(" pilin md5Str " + md5Str);

        map.put("sign", md5Str);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("pilin pilin map " + map);

        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl hongyiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("version", "3.0");
        map.put("method", "Gt.online.interface");
        map.put("partner", platMer.getMerKey());
        map.put("banktype", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("paymoney", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("ordernumber", platMerOrderParam.getOrderId());
        map.put("callbackurl", channel.getNotifyUrl());

        String s = convertUrlIsEmptyObject(map, "&", "=") + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toLowerCase();
        map.put("sign", sign);
        map.put("notreturnpage", true);
        log.info("hongYi s " + s);
        log.info("hongYi sign " + sign);

        map.put("hrefbackurl", channel.getNotifyUrl());
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("hongYi map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getInteger("code").intValue() == 0) {
            log.info("hongYi success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hongYi return null");
        return null;
    }

    public PayUrl happyxybUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        return hongyiUrl(platMer, platMerBaseCode, platMerOrderParam, channel);

    }

    public PayUrl xgpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        return pfpayUrl(platMer, platMerBaseCode, platMerOrderParam, channel);

    }

    public PayUrl jinxinUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", "1ed60025ab0e467fad04919b0649055c");
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("extra", "{\"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("codeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }

    public PayUrl upayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("bizNum", platMerOrderParam.getOrderId());
        map.put("merchantId", platMer.getMerKey());
        map.put("money", platMerOrderParam.getAmount().multiply(new BigDecimal(100)));
        map.put("notifyAddress", channel.getNotifyUrl());
        map.put("type", "recharge");
        map.put("userId", RandomUtils.nextInt());
        map.put("key", platMer.getPrivateKey());
        log.info("upay launch map " + map);

        String s = convertUrlIsEmptyObject(map, "&", "=");
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("upay launch s " + s);
        log.info("upay launch md5(s) " + sign);

        map.remove("key");
        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("upay launch map " + map);

        log.info("upay launch succes");
        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl basecodUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
            map.put("oid_partner", platMer.getMerKey());
        map.put("notify_url", channel.getNotifyUrl());
        map.put("user_id", RandomUtils.nextInt());
        map.put("sign_type", "MD5");
        map.put("no_order", platMerOrderParam.getOrderId());
        SimpleDateFormat sdf = new SimpleDateFormat("YYYYMMDDHHmmss");
        map.put("time_order", sdf.format(new Date()));
        DecimalFormat df = new DecimalFormat("0.00");
        map.put("money_order", df.format(platMerOrderParam.getAmount()));
        map.put("name_goods", "test");
        map.put("pay_type", platMerBaseCode.getBaseCode());

        String s = convertUrlNotEmpty(map, "&", "=") + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);
        map.put("sign", sign);
        log.info("basecod launch s " + s);
        log.info("basecod launch sign " + sign);

        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("basecod launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("basecod launch body info data {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("0000".equals(jsonObject.getString("ret_code"))) {
            log.info("basecod launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("redirect_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("basecod return null");
        return null;
    }

    public PayUrl gxyxUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        return dongyaYihaoPayUrl(platMer, platMerBaseCode, platMerOrderParam, channel);

    }

    public PayUrl caiyingUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return dongyaYihaoPayUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl yuanwangUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("bill_id", platMerOrderParam.getOrderId());
        map.put("goods_name", "test");
        map.put("amount", platMerOrderParam.getAmount());
        map.put("goods_note", "test");
        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD HH:mm:ss");
        map.put("mch_bill_time", sdf.format(new Date()));
        map.put("notify_url", channel.getNotifyUrl());
        map.put("return_url", channel.getNotifyUrl());
        map.put("version", "2");
        map.put("mch_id", platMer.getMerKey());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        map.put("mch_app", platMer.getPublicKey());
        map.put("user_ip", "127.0.0.1");

        String s = convertUrlNotEmpty(map, "&", "=") + "&mch_key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);
        log.info("yuanwan launch s " + s);
        log.info("yuanwan launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("yuanwan launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("yuanwan launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("E000").equals(jsonObject.getString("code"))) {
            log.info("yuanwan launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("qrCode"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("yuanwan launch return null");
        return null;
    }

    public PayUrl xiaozhoutongUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("pid", platMer.getMerKey());
        map.put("type", platMerBaseCode.getBaseCode());
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("notify_url", channel.getNotifyUrl());
        map.put("return_url", channel.getNotifyUrl());
        map.put("name", "test");
        DecimalFormat df = new DecimalFormat();
        map.put("money", df.format(platMerOrderParam.getAmount()));
        log.info("xiaozhoutong launch map " + map);

        String s = convertUrlIsEmptyObject(map, "&", "=") + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);
        log.info("xiaozhoutong launch s " + s);
        log.info("xiaozhoutong launch md5(s) " + sign);
        map.put("sign_type", "MD5");
        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("xiaozhoutong launch map " + map);

        log.info("xiaozhoutong launch succes");
        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl qmpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("serverNum", platMer.getMerKey());
        map.put("amount", platMerOrderParam.getAmount().toString());
        map.put("transNumber", platMerOrderParam.getOrderId());
        map.put("payType", platMerBaseCode.getBaseCode());
        map.put("notifyUrl", channel.getNotifyUrl());

        String s = map.get("serverNum").toString() + map.get("amount").toString() +
                map.get("transNumber").toString() + map.get("payType").toString() + map.get("notifyUrl").toString();
        String sign = SecureUtil.md5(SecureUtil.md5(s) + platMer.getPrivateKey()).toLowerCase();

        log.info("qmpay launch s " + s);
        log.info("qmpay launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("qmpay launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("qmpay launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("qmpay launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("qmpay launch return null");
        return null;
    }


    @Override
    public PayUrl jinshunfuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("merCode", platMer.getMerKey());
        map.put("saveWayCode", platMerBaseCode.getBaseCode());
        map.put("bankCode", platMerBaseCode.getBaseCode());
        map.put("amount", String.format("%.2f", platMerOrderParam.getAmount()));
        map.put("merOrderId", platMerOrderParam.getOrderId());
        map.put("notifyUrl", channel.getNotifyUrl());


        log.error("jinshunfu {}", convertUrlNotEmpty(map, "&", "="));
        String sign = SecureUtil.md5(convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey()).toLowerCase();

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("qmpay launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("qmpay launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("rechargeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        return null;
    }

    public PayUrl huaxinUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", "221aa012afea4d5282e37ede07136a55");
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("extra", "");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("huaxin launch s " + s);
        log.info("huaxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("huaxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("huaxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("huaxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("jumpUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("huaxin launch return null");
        return null;
    }


    @Override
    public PayUrl juziPayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("merchant", platMer.getMerKey());
        map.put("qrtype", platMerBaseCode.getBaseCode());
        map.put("customno", platMerOrderParam.getOrderId());
        map.put("money", String.format("%.2f", platMerOrderParam.getAmount()));
        map.put("sendtime", (System.currentTimeMillis() / 1000));
        map.put("notifyurl", channel.getNotifyUrl());
        map.put("backurl", "http://www.baidu.com");
        map.put("risklevel", "1");

        String s = convertUrlIsEmptyObject(map, "&", "=") + platMer.getPrivateKey();

        log.info("juzi launch s " + s);
        String sign = SecureUtil.md5(s);
        log.info("juzi launch md5(s) " + sign);
        map.put("sign", sign.toLowerCase());
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("juzi launch map " + map);

        log.info("juzi launch succes");
        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    @Override
    public PayUrl xinfubaoPayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("uid", platMer.getMerKey());
        map.put("code", platMerBaseCode.getBaseCode());
        map.put("orderid", platMerOrderParam.getOrderId());
        map.put("price", String.format("%.2f", platMerOrderParam.getAmount()));
        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD HH:mm:ss");
        map.put("addtime", sdf.format(new Date()));
        map.put("notify", channel.getNotifyUrl());
        map.put("back", "http://www.baidu.com");
        String s = convertUrlIsEmptyObject(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        log.info("juziPayUrl launch s " + s);
        String sign = SecureUtil.md5(s);
        log.info("juziPayUrl launch md5(s) " + sign);
        map.put("sign", sign.toUpperCase());


        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl yftpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        return yinFuTongUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl yhpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        return yinFuTongUrl(platMer, platMerBaseCode, platMerOrderParam, channel);

    }

    public PayUrl meiruibaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("version", 1);
        map.put("customer_id", platMer.getMerKey());
        map.put("customer_order_no", platMerOrderParam.getOrderId());
        DecimalFormat df = new DecimalFormat("0.00");
        map.put("money", df.format(platMerOrderParam.getAmount()));
        map.put("pay_type", platMerBaseCode.getBaseCode());
        map.put("return_type", "1");
        map.put("notify_url", channel.getNotifyUrl());
        map.put("return_url", channel.getNotifyUrl());
        map.put("remark", "test");
//        map.put("key", platMer.getPrivateKey());

        String s = convertUrlIsEmptyObject(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);
        log.info("meiruibao launch s " + s);
        log.info("meiruibao launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("meiruibao launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("meiruibao launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("10000").equals(jsonObject.getString("status"))) {
            log.info("meiruibao launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("meiruibao launch return null");
        return null;
    }

    public PayUrl hnpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String, Object> map = new LinkedHashMap<>();
        map.put("parter", platMer.getMerKey());
        map.put("type", platMerBaseCode.getBaseCode());
        DecimalFormat df = new DecimalFormat("0.00");
        map.put("value", df.format(platMerOrderParam.getAmount()));
        map.put("orderid", platMerOrderParam.getOrderId());
        map.put("callbackurl", channel.getNotifyUrl());


//parter={}&type={}&value={}&orderid={}&callbackurl={}key
        String s = convertUrlIsEmptyObject(map, "&", "=") + "" + platMer.getPrivateKey();
        map.put("return_type", "1");
        map.put("hrefbackurl", channel.getNotifyUrl());
        log.info("meiruibao launch s " + s);
        String sign = SecureUtil.md5(s);
        map.put("sign", sign);


        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

    }

    public PayUrl wykktUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("userId", platMer.getMerKey());
        DecimalFormat df = new DecimalFormat("0.00");
        map.put("tradeAmt", df.format(platMerOrderParam.getAmount()));
        map.put("orderRemark", platMerOrderParam.getOrderId());
        map.put("nbNotifyUrl", channel.getNotifyUrl());
        map.put("key", platMer.getPrivateKey());

        StringBuilder s = new StringBuilder("");
        map.forEach((k, v) -> s.append(v));

        String sign = SecureUtil.md5(s.toString()).toUpperCase();
        log.info("wykkt launch s {}", s.toString());

        map.remove("key");
        map.put("hmac", sign);
        log.info("wykkt launch md5(s) " + sign);

        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("wykkt launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("wykkt launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("000").equals(jsonObject.getString("code"))) {
            log.info("wykkt launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("obj").getString("h5_url") + "?id=" + jsonObject.getJSONObject("obj").getString("id") + "&userId=" + platMer.getMerKey(), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("wykkt launch return null");
        return null;
    }

    public PayUrl fcpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("pay_memberid", platMer.getMerKey());
        map.put("pay_orderid", platMerOrderParam.getOrderId());
        map.put("price", (new BigDecimal(100).multiply(platMerOrderParam.getAmount())).intValue());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        map.put("pay_notifyurl", channel.getNotifyUrl());
        map.put("pay_callbackurl", channel.getNotifyUrl());

        String s = convertUrlIsEmptyObject(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("fcpay launch s " + s);
        log.info("fcpay launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("fcpay launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("fcpay launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("retcode"))) {
            log.info("fcpay launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("fcpay launch return null");
        return null;
    }

    public PayUrl jiexunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        return yinFuTongUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl theUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("memberid", platMer.getMerKey());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        map.put("trade_no", platMerOrderParam.getOrderId());
        DecimalFormat df = new DecimalFormat("0.00");
        map.put("amount", df.format(platMerOrderParam.getAmount()));
        map.put("notify_url", channel.getNotifyUrl());

        String s = convertUrlIsEmptyObject(map, "&", "=") + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s);
        log.info("the launch s " + s);
        log.info("the launch md5(s) " + sign);

        map.put("sign", sign);
        map.put("json", "1");
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("the launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("the launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("the launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("qrcode"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("the launch return null");
        return null;
    }

    public PayUrl sjpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("appid", platMer.getMerKey());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("callback_url", channel.getNotifyUrl());
        map.put("success_url", channel.getNotifyUrl());
        map.put("error_url", channel.getNotifyUrl());
        map.put("out_uid", "15017399440");
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("version", "v2.0");
        log.info(" sjpayUrl map " + map);

        StringBuilder s = new StringBuilder("");
        for (String key : map.keySet()) {
            if (null != map.get(key) && !"".equals(map.get(key))) {
                s.append(key).append("=").append(map.get(key)).append("&");
            }
        }
        s.append("key").append("=").append(platMer.getPrivateKey());
        log.info("sjpayUrl s " + s);

        String md5Str = SecureUtil.md5(s.toString()).toUpperCase();
        log.info(" sjpayUrl md5Str " + md5Str);

        map.put("sign", md5Str);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("sjpayUrl pilin map " + map);

        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl kkpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        return yinFuTongUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl andaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws Exception {
        Map<String, Object> map = new TreeMap<>();
        map.put("order_no", platMerOrderParam.getOrderId());

        map.put("gateway", "alipay");
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("ip", "127.0.0.1");
        map.put("return_url", channel.getNotifyUrl());
        map.put("notify_url", channel.getNotifyUrl());
        log.info(" anda map " + map);

        String s = JSONObject.toJSONString(map);
        log.info("anda s " + s);

        String sign = java_openssl_encrypt(s, platMer.getPrivateKey(), platMer.getPublicKey());

        log.info(" anda md5Str " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("anda pilin map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("anda launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("true").equals(jsonObject.getString("ok"))) {
            log.info("anda launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        return null;
    }


    public PayUrl kaijiaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("appId", platMer.getMerKey());
        map.put("version", "1.0");
        map.put("amount", new BigDecimal(100).multiply(platMerOrderParam.getAmount()));
        map.put("customOrderId", platMerOrderParam.getOrderId());
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("callbackUrl", channel.getNotifyUrl());
        map.put("payType", platMerBaseCode.getBaseCode());
        map.put("remark", RandomUtil.randomInt(10) + "");
        map.put("responseType", "JSON");
        map.put("ip", "127.0.0.1");
        log.info(" kaijia map " + map);

        String s = appendValue(map) + platMer.getPrivateKey();
        log.info("kaijia s " + s);

        String md5Str = SecureUtil.md5(s.toString());
        log.info(" kaijia md5Str " + md5Str);

        map.put("sign", md5Str);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("kaijia map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("kaijia launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("1").equals(jsonObject.getString("code"))) {
            log.info("kaijia launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("the launch return null");
        return null;
    }


    public PayUrl XGUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new LinkedHashMap();
        sortedMap.put("fxid", platMer.getMerKey());
        sortedMap.put("fxddh", platMerOrderParam.getOrderId());
        sortedMap.put("fxdesc", "test");
        sortedMap.put("fxfee", String.format("%.2f", platMerOrderParam.getAmount()));
        sortedMap.put("fxattch", "test");
        sortedMap.put("fxip", "127.0.0.1");
        sortedMap.put("fxpay", platMerBaseCode.getBaseCode());
//        sortedMap.put("pay_bankcode", platMerBaseCode.getBankCode());
        sortedMap.put("fxnotifyurl", channel.getNotifyUrl());
        sortedMap.put("fxbackurl", "http://www.baidu.com");
//        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        String s = sortedMap.get("fxid").toString() + sortedMap.get("fxddh").toString() + sortedMap.get("fxfee").toString() + sortedMap.get("fxnotifyurl").toString() + platMer.getPrivateKey();
        log.info("XG a qbf {}", s);
        String sign = SecureUtil.md5(s).toLowerCase();
        sortedMap.put("fxsign", sign);
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("XG launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("1").equals(jsonObject.getString("status"))) {
            log.info("XG launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        return null;
    }

    public PayUrl xiaocaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("merId", platMer.getMerKey());
        sortedMap.put("businessOrderId", platMerOrderParam.getOrderId());
        sortedMap.put("tradeMoney", platMerOrderParam.getAmount());
        sortedMap.put("payType", platMerBaseCode.getBaseCode());
        sortedMap.put("asynURL", channel.getNotifyUrl());

        String s = convertUrlNotEmpty(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        log.info("xiaocao a qbf {}", s);
        String sign = SecureUtil.md5(s);
        sortedMap.put("sign", sign);
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("map {}", sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("xiaocao launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("1000").equals(jsonObject.getString("code"))) {
            log.info("xiaocao launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("pcodeurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("xiaocao launch error");
        return null;
    }

    public PayUrl dongyayifaPayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws Exception {
        Map<String, Object> map = new TreeMap<>();
        map.put("appid", platMer.getMerKey());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("callback_url", channel.getNotifyUrl());
        map.put("success_url", channel.getNotifyUrl());
        map.put("error_url", channel.getNotifyUrl());
        map.put("out_uid", "15017399440");
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("version", "v2.0");
        log.info(" pilin map " + map);
        map.put("return_type", "");
        StringBuilder s = new StringBuilder("");
        for (String key : map.keySet()) {
            if (null != map.get(key) && !"".equals(map.get(key))) {
                s.append(key).append("=").append(map.get(key)).append("&");
            }
        }
        s.append("key").append("=").append(platMer.getPrivateKey());
        log.info("pilin s " + s);

        String md5Str = SecureUtil.md5(s.toString()).toUpperCase();
        log.info(" pilin md5Str " + md5Str);

        map.put("sign", md5Str);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("pilin pilin map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("shangshangkejiPayUrl launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("kaijia launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("qrcode"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        throw new Exception("create shangshangkejiPayUrl error");
    }

    public PayUrl shangshangkejiPayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws Exception {

        Map<String, Object> map = new TreeMap<>();
        map.put("appid", platMer.getMerKey());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("callback_url", channel.getNotifyUrl());
        map.put("success_url", channel.getNotifyUrl());
        map.put("error_url", channel.getNotifyUrl());
        map.put("out_uid", "15017399440");
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("version", "v2.0");
        log.info(" pilin map " + map);

        StringBuilder s = new StringBuilder("");
        for (String key : map.keySet()) {
            if (null != map.get(key) && !"".equals(map.get(key))) {
                s.append(key).append("=").append(map.get(key)).append("&");
            }
        }
        s.append("key").append("=").append(platMer.getPrivateKey());
        log.info("pilin s " + s);

        String md5Str = SecureUtil.md5(s.toString()).toUpperCase();
        log.info(" pilin md5Str " + md5Str);

        map.put("sign", md5Str);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("pilin pilin map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("shangshangkejiPayUrl launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("kaijia launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("qrcode"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        throw new Exception("create shangshangkejiPayUrl error");
    }


    public PayUrl chuanyepayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", "0ae8be35ff634e2abe94f5f32f6d5c4f");
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("extra", "{\"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}\t");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("codeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }


    public PayUrl dongyakkpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        return caiyingUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl huoteUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return caiyingUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
//        SortedMap<String, Object> sortedMap = new TreeMap();
//        sortedMap.put("mch_id", platMer.getMerKey());
//        sortedMap.put("ptype", 1);
//        sortedMap.put("order_sn", platMerOrderParam.getOrderId());
//        DecimalFormat df = new DecimalFormat("0.00");
//        sortedMap.put("money", df.format(platMerOrderParam.getAmount()));
//        sortedMap.put("goods_desc", "test");
//        sortedMap.put("client_ip", "127.0.0.1");
//        sortedMap.put("format", "json");
//        sortedMap.put("notify_url", channel.getNotifyUrl());
//        sortedMap.put("time", (System.currentTimeMillis() / 1000) + "");
//
//        String s = convertUrlIsEmptyObject(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
//        String sign = SecureUtil.md5(s);
//        log.info("huote a qbf {}", s);
//
//        sortedMap.put("sign", sign);
////        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
//        log.info("huote map {}", sortedMap);
//
//        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
//        log.info( "huote launch body {}", body);
//        JSONObject jsonObject = JSONObject.parseObject(body);
//        if (("1").equals(jsonObject.getString("code"))) {
//            log.info("huote launch success");
//            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString( "qrcode"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
//        }
//
//        log.error("huote launch error");
//        return null;
    }

    public PayUrl jiebaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("MerId", platMer.getMerKey());
        sortedMap.put("PayType", platMerBaseCode.getBaseCode());
        sortedMap.put("MerOrderNo", platMerOrderParam.getOrderId());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
        sortedMap.put("MerOrderTime", sdf.format(new Date()));
        sortedMap.put("Amount", String.valueOf(platMerOrderParam.getAmount().multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)).intValue()));
        sortedMap.put("NotifyUrl", channel.getNotifyUrl());

        sortedMap.put("Version", 3);

        String s = convertUrlNotEmpty(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        log.info("jiebao a qbf {}", s);
        String sign = SecureUtil.md5(s);
        sortedMap.put("sign", sign);
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("jiebao launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("success").equals(jsonObject.getString("code"))) {
            log.info("jiebao launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("QrcodeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("jiebao launch error");
        return null;
    }

    public PayUrl sixsixUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new LinkedHashMap<>();
        sortedMap.put("appId", platMer.getMerKey());
        sortedMap.put("version", "1.0");
        sortedMap.put("amount", platMerOrderParam.getAmount().multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)));
        sortedMap.put("customOrderId", platMerOrderParam.getOrderId());
        sortedMap.put("Amount", platMerOrderParam.getAmount().multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)));
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("callbackUrl", channel.getNotifyUrl());
        sortedMap.put("payType", platMerBaseCode.getBaseCode());
        sortedMap.put("remark", "test");
        sortedMap.put("responseType", "JSON");
        sortedMap.put("ip", "127.0.0.1");

        StringBuilder sb = new StringBuilder("");
        for (Map.Entry<String, Object> entry : sortedMap.entrySet()) {
            sb.append(entry.getValue());
        }
        sb.append(platMer.getPrivateKey());

        String s = sb.toString();

        log.info("sixsix a qbf {}", s);
        String sign = SecureUtil.md5(s);
        sortedMap.put("sign", sign);
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("sixsix launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("1").equals(jsonObject.getString("code"))) {
            log.info("sixsix launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("sixsix launch error");
        return null;
    }

    public PayUrl yiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("app_id", platMer.getMerKey());
        sortedMap.put("nonce_str", RandomUtil.randomNumbers(10));
        sortedMap.put("trade_type", platMerBaseCode.getBaseCode());
        sortedMap.put("total_amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100)).intValue() + ""));
        sortedMap.put("out_trade_no", platMerOrderParam.getOrderId());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        sortedMap.put("trade_time", sdf.format(new Date()));
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("user_ip", "127.0.0.1");

        String s = convertUrlNotEmpty(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();

        log.info("yi a qbf {}", s);
        String sign = SecureUtil.md5(s).toUpperCase();
        sortedMap.put("sign", sign);
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("yi a map {}", sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("yi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("0000").equals(jsonObject.getString("code"))) {
            log.info("yi launch success");
            return new PayUrl(1, channel.getChannelCode(), ((jsonObject.containsKey("code_wap") && StringUtils.isNotEmpty(jsonObject.getString("code_wap"))) ? jsonObject.getString("code_wap") : jsonObject.getString("code_url")), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("yi launch error");
        return null;
    }

    public PayUrl caiyingNewUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("merchantNum", platMer.getMerKey());
        sortedMap.put("orderNo", platMerOrderParam.getOrderId());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        sortedMap.put("out_trade_no", platMerOrderParam.getOrderId());
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("payType", platMerBaseCode.getBaseCode());

        String signUrl = platMer.getMerKey() + platMerOrderParam.getOrderId() + decimalFormat.format(platMerOrderParam.getAmount()) + channel.getNotifyUrl() + platMer.getPrivateKey();
        sortedMap.put("sign", SecureUtil.md5(signUrl).toLowerCase());

        sortedMap.put("returnUrl", "http://www.baidu.com");
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("yi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("yi launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("yi launch error");
        return null;
    }

    public PayUrl kaerNewUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("merchantNum", platMer.getMerKey());
        sortedMap.put("orderNo", platMerOrderParam.getOrderId());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        sortedMap.put("out_trade_no", platMerOrderParam.getOrderId());
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("payType", platMerBaseCode.getBaseCode());

        String signUrl = platMer.getMerKey() + platMerOrderParam.getOrderId() + decimalFormat.format(platMerOrderParam.getAmount()) + channel.getNotifyUrl() + platMer.getPrivateKey();
        sortedMap.put("sign", SecureUtil.md5(signUrl).toLowerCase());

        sortedMap.put("returnUrl", "http://www.baidu.com");
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("yi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("yi launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("yi launch error");
        return null;
    }

    public PayUrl ukafuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());
        sortedMap.put("pay_type", "json");

        String s = convertUrl(sortedMap, "&", "=");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        s = s + "&pay_productname=test&pay_md5sign=" + sign;
        String createUrl = channel.getCreateUrl();
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("pay_md5sign", sign);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);

        return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());


    }


    public PayUrl jxpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());
        sortedMap.put("pay_return_type", "html");
        String s = convertUrl(sortedMap, "&", "=");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        s = s + "&pay_productname=test&pay_md5sign=" + sign;
        String createUrl = channel.getCreateUrl();

        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl qpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        return hngmpayUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl hngmpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("appid", platMer.getMerKey());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("callback_url", channel.getNotifyUrl());
        map.put("success_url", channel.getNotifyUrl());
        map.put("error_url", channel.getNotifyUrl());
        map.put("out_uid", "15017399440");
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("version", "v1.1");
        log.info(" pilin map " + map);

        StringBuilder s = new StringBuilder("");
        for (String key : map.keySet()) {
            if (null != map.get(key) && !"".equals(map.get(key))) {
                s.append(key).append("=").append(map.get(key)).append("&");
            }
        }
        s.append("key").append("=").append(platMer.getPrivateKey());
        log.info("pilin s " + s);

        String md5Str = SecureUtil.md5(s.toString()).toUpperCase();
        log.info(" pilin md5Str " + md5Str);

        map.put("sign", md5Str);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("pilin pilin map " + map);

        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl dongyaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("Amount", platMerOrderParam.getAmount());
        sortedMap.put("Ip", "127.0.0.1");
        sortedMap.put("MerchantId", platMer.getMerKey());
        sortedMap.put("MerchantUniqueOrderId", platMerOrderParam.getOrderId());
        sortedMap.put("NotifyUrl", channel.getNotifyUrl());
        sortedMap.put("PayTypeId", platMerBaseCode.getBaseCode());
        sortedMap.put("ReturnUrl", channel.getNotifyUrl());

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("dongya a map {}", sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("dongya launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("0").equals(jsonObject.getString("Code"))) {
            log.info("dongya launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("Url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("dongya launch error");
        return null;
    }

    public PayUrl hengShengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new HashMap<>();
        sortedMap.put("mchId", platMer.getMerKey());
        sortedMap.put("appId", "cb0ec3a365f0456ea604c8500d9767ce");
        sortedMap.put("mchOrderNo", platMerOrderParam.getOrderId());
        sortedMap.put("currency", "cny");
        sortedMap.put("amount", platMerOrderParam.getAmount().multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)));
        sortedMap.put("notifyU rl", channel.getNotifyUrl());
        sortedMap.put("subject", "test");
        sortedMap.put("body", "test");

        Map<String, String> extraMap = new HashMap<>();
        extraMap.put("timeout_express", "10m");
        extraMap.put("returnType", "URL");
        sortedMap.put("extra", extraMap);


        String s = convertUrlNotEmpty(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        String md5 = SecureUtil.md5(s).toUpperCase();
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", md5);

        log.info("hengSheng a map {}", sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("hengSheng launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("hengSheng launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("hengSheng launch error");
        return null;
    }

    public PayUrl ncgepayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        Map signData = new LinkedHashMap();
        signData.put("ip", "127.0.0.1");

        signData.put("merchantNo", platMer.getMerKey());
        signData.put("money", String.format("%.2f", platMerOrderParam.getAmount()));
        signData.put("notify", channel.getNotifyUrl());
        signData.put("out_trade_no", platMerOrderParam.getOrderId());
        signData.put("pay", platMerBaseCode.getBaseCode());

        String s = convertUrlIsEmpty(signData, "&", "=");


        String sign = SecureUtil.md5(s + "&secret=" + platMer.getPrivateKey()).toUpperCase();

        log.info("s {}", s);
        log.info("sign {}", sign);

        String createUrl = channel.getCreateUrl();
        String body = HttpUtil.createGet(createUrl + "?" + convertUrl(signData, "&", "=") + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign).execute().body();

        log.info("body {}", body);

        JSONObject jsonObject = JSONObject.parseObject(body);
        log.error(" response ao pay {}", jsonObject.toJSONString());
        if (jsonObject.getInteger("code").intValue() == 200) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return null;
    }

    public PayUrl sfkjUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", "b5cb5250f95642ae96b1add4c89d85d4");
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("extra", "");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }

    public PayUrl hskjpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", "cb0ec3a365f0456ea604c8500d9767ce");
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
//        map.put("extra", "{\"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}\t");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("codeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }

    public PayUrl zfbUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("appid", platMer.getMerKey());
        map.put("pay_type", "alipay");
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("callback_url", channel.getNotifyUrl());
        map.put("success_url", channel.getNotifyUrl());
        map.put("error_url", channel.getNotifyUrl());
        map.put("out_uid", "15017399440");
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("version", "v1.1");
        log.info(" pilin map " + map);
//        map.put("return_type", "app");
        StringBuilder s = new StringBuilder("");
        for (String key : map.keySet()) {
            if (null != map.get(key) && !"".equals(map.get(key))) {
                s.append(key).append("=").append(map.get(key)).append("&");
            }
        }
        s.append("key").append("=").append(platMer.getPrivateKey());
        log.info("zfb s " + s);

        String md5Str = SecureUtil.md5(s.toString()).toUpperCase();
        log.info(" zfb md5Str " + md5Str);

        map.put("sign", md5Str);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("zfb pilin map " + map);

//        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("zfb launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("zfb launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("qrcode"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("zfb launch error");
        return null;
    }

    public PayUrl chengziUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws Exception {
        return juziPayUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl youjiaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws Exception {
        return dongyayifaPayUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl hspayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("machid", platMer.getMerKey());

        map.put("type", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("orderid", platMerOrderParam.getOrderId());

        map.put("callbackurl", channel.getNotifyUrl());


//        map.put("extra", "{\"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}\t");

        String s = convertUrlNotEmpty(map, "&", "=") + platMer.getPrivateKey();


        map.put("ip", "127.0.0.1");
        String sign = SecureUtil.md5(s).toLowerCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        map.put("method", "get");
        log.info("jinxin launch map " + map);

        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl baochenUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws Exception {
        Map<String, Object> map = new TreeMap<>();
        map.put("orderNo", platMerOrderParam.getOrderId());
        map.put("appId", platMer.getMerKey());
        DecimalFormat df = new DecimalFormat("0.00");
        map.put("money", df.format(platMerOrderParam.getAmount()));
        map.put("returnUrl", channel.getNotifyUrl());
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("productName", "test");

        log.info(" baochen map " + map);
//        map.put("return_type", "app");
        StringBuilder s = new StringBuilder("");
        for (String key : map.keySet()) {
            if (null != map.get(key) && !"".equals(map.get(key))) {
                s.append(key).append("=").append(map.get(key)).append("&");
            }
        }
        s.append("key").append("=").append(platMer.getPrivateKey());
        log.info("zfb s " + s);

        String md5Str = SecureUtil.md5(s.toString());
        log.info(" baochen md5Str " + md5Str);

        map.put("sign", md5Str);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("baochen pilin map " + map);

//        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("baochen launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("0").equals(jsonObject.getString("code"))) {
            log.info("baochen launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("obj"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("baochen launch error");
        return null;
    }

    public PayUrl oreoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("Number", platMer.getMerKey());
        sortedMap.put("MerTradeID", platMerOrderParam.getOrderId());
        sortedMap.put("MerProductID", RandomUtil.randomNumbers(10) + "");
        sortedMap.put("MerUserID", RandomUtil.randomNumbers(10) + "");
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("Amount", decimalFormat.format(platMerOrderParam.getAmount()));
        sortedMap.put("NotifyUrl", channel.getNotifyUrl());
        String createUrl = channel.getRealUrl();

        log.info("saveWayCode {}", platMerOrderParam.getSaveWayCode());

//        if(platMerOrderParam.getSaveWayCode().equals("unipay")){
//            createUrl = createUrl+"/Pay/YsfPayment.php";
//        }

        String s = convertUrlNotEmpty(sortedMap, "&", "=") + "&Key=" + platMer.getPrivateKey();
        log.info("oreo sign mw {}", s);

        String sign = SecureUtil.md5(s).toLowerCase();
        sortedMap.put("Sign", sign);
//        sortedMap.put(Epay.REAL_URL, createUrl);

        log.info("oreo map {}", sortedMap);

        log.info("oreo launch success");

        log.info("url {}", channel.getCreateUrl() + "?" + convertUrlNotEmpty(sortedMap, "&", "="));

        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlNotEmpty(sortedMap, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl dyUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws Exception {
        Map<String, Object> map = new TreeMap<>();
        map.put("appId", platMer.getMerKey());
        map.put("orderId", platMerOrderParam.getOrderId());
//        DecimalFormat df = new DecimalFormat("0.00");
//        map.put("amount", df.format(platMerOrderParam.getAmount()));
        map.put("amount", platMerOrderParam.getAmount());
        map.put("payType", "5");
        map.put("remark", "test");
        map.put("clientUrl", channel.getNotifyUrl());
        map.put("notifyUrl", channel.getNotifyUrl());
        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
        map.put("time", sdf.format(new Date()));

        log.info(" dy map " + map);

        String s = convertUrlIsEmptyObject(map, "&", "=") + platMer.getPrivateKey();
        log.info("dy s " + s);

        String md5Str = SecureUtil.md5(s).toLowerCase();
        log.info(" dy md5Str " + md5Str);

        map.put("sign", md5Str);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("dy pilin map " + map);

        log.info("success");
        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl jinpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());

        String s = convertUrl(sortedMap, "&", "=");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        String createUrl = channel.getCreateUrl();
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("pay_md5sign", sign);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getInteger("state").intValue() == 1) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

    }

    public PayUrl xunyinUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return qianbaoUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl zhongbiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, String> sortedMap = new HashMap();
        sortedMap.put("merchantId", platMer.getMerKey());
        sortedMap.put("timestamp", new Date().getTime() + "");
//        sortedMap.put("timestamp", "1585548258000");
        sortedMap.put("signatureMethod", "HmacSHA256");
        sortedMap.put("signatureVersion", "1");
        sortedMap.put("jUserId", UUID.randomUUID().toString().replaceAll("-", ""));
        sortedMap.put("jUserIp", "127.0.0.1");
        sortedMap.put("jOrderId", platMerOrderParam.getOrderId());
        sortedMap.put("orderType", "1");
        sortedMap.put("payWay", platMerBaseCode.getBaseCode());
        DecimalFormat df = new DecimalFormat("0.00");
        sortedMap.put("amount", df.format(platMerOrderParam.getAmount()));
        sortedMap.put("currency", "CNY");
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("jExtra", "123");

        String sign = DigestUtil.createSign(sortedMap, platMer.getPrivateKey());

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("signature", sign);

        Map<String, Object> m = new HashMap();
        m.putAll(sortedMap);
        log.info("map {}", m);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(m).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);

        log.info("result a zhongbi {}", body);
        if (jsonObject.getInteger("code").intValue() == 0) {
            log.info("success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("paymentUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        return null;
    }

    public PayUrl tailianUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, String> sortedMap = new TreeMap<>();
        sortedMap.put("customer_no", platMer.getMerKey());
        sortedMap.put("customer_order", platMerOrderParam.getOrderId());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        sortedMap.put("produce_date", sdf.format(new Date()));
        sortedMap.put("bank_code", platMerBaseCode.getBaseCode());
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("callback_url", channel.getNotifyUrl());
        DecimalFormat df = new DecimalFormat("0.00");
        sortedMap.put("amount", df.format(platMerOrderParam.getAmount()));

        String s = convertUrl(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        log.info("s {}", s);

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("sign {}", sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign_md5", sign);
        sortedMap.put("goods_name", "test");

        log.info("map {}", sortedMap);

        String url = channel.getCreateUrl() + "?" + convertUrl(sortedMap, "&", "=");
        log.info("url {}", url);

        log.info("tailian success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl yinkeUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return meiruibaoUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl yonghuapayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        return yinFuTongUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl baijiaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, String> sortedMap = new TreeMap<>();
        sortedMap.put("merCode", platMer.getMerKey());
        sortedMap.put("tranNo", platMerOrderParam.getOrderId());
        sortedMap.put("tranType", "00");
        sortedMap.put("tranAmt", platMerOrderParam.getAmount().multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)).toString());
        sortedMap.put("collectWay", platMerBaseCode.getBaseCode());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        sortedMap.put("tranTime", sdf.format(new Date()));
//      sortedMap.put("bankCode", "1");

        sortedMap.put("noticeUrl", channel.getNotifyUrl());
        sortedMap.put("orderDesc", "desc");


        String s = convertUrl(sortedMap, "&", "=") + platMer.getPrivateKey();
        log.info("s {}", s);

        String sign = SecureUtil.md5(s);
        log.info("sign {}", sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);

        log.info("map {}", sortedMap);

        String url = channel.getCreateUrl() + "?" + convertUrl(sortedMap, "&", "=");
        log.info("url {}", url);

        log.info("baijia success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl anranUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new HashMap<>();
        sortedMap.put("appKey", platMer.getMerKey());
        sortedMap.put("outOrderId", platMerOrderParam.getOrderId());
        sortedMap.put("orderFund", platMerOrderParam.getAmount());
        sortedMap.put("callbackUrl", channel.getNotifyUrl());

        String plaintext = "appKey=" + sortedMap.get("appKey")
                + "outOrderId=" + sortedMap.get("outOrderId")
                + "orderFund=" + sortedMap.get("orderFund")
                + "callbackUrl=" + sortedMap.get("callbackUrl")
                + "key=" + platMer.getPrivateKey();
        log.info("s {}", plaintext);

        String sign = SecureUtil.md5(plaintext).toLowerCase();

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);
        sortedMap.put("payType", platMerBaseCode.getBaseCode());

        log.info("map {}", sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);

        log.info("result a zhongbi {}", body);
        if (jsonObject.getInteger("code").intValue() == 0) {
            log.info("success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pcUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        return null;
    }

    public PayUrl acUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        return kuaizhifuUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl kuaizhifuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, String> sortedMap = new TreeMap<>();
        sortedMap.put("version", "1.0");
        sortedMap.put("mch_id", platMer.getMerKey());
        sortedMap.put("out_trade_no", platMerOrderParam.getOrderId());
        DecimalFormat df = new DecimalFormat("0.00");
        sortedMap.put("total_fee", df.format(platMerOrderParam.getAmount()));
        sortedMap.put("pay_type", platMerBaseCode.getBaseCode());
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("return_url", channel.getNotifyUrl());

        String s = convertUrl(sortedMap, "&", "=") + "&" + platMer.getPrivateKey();
        log.info("s {}", s);

        String sign = SecureUtil.md5(s).toLowerCase();
        log.info("sign {}", sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);

        log.info("map {}", sortedMap);

        String url = channel.getCreateUrl() + "?" + convertUrl(sortedMap, "&", "=");
        log.info("url {}", url);

        log.info("kuaizhifu success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }


    public PayUrl luoyaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam
            platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());

        String s = convertUrl(sortedMap, "&", "=");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        s = s + "&pay_productname=test&pay_md5sign=" + sign;

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("pay_md5sign", sign);


        String url = channel.getCreateUrl() + "?" + convertUrl(sortedMap, "&", "=");
        log.info("url {}", url);

        log.info("luoyao success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl txpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", "33ff214a34cc47e78135b5acb198b346");
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
//        map.put("extra", "{\"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("shun launch s " + s);
        log.info("shun launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("shun launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("shun launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("shun launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("codeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("shun launch return null");
        return null;
    }

    public PayUrl shunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", "77daa07265964ce2845346bba248c29c");
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
//        map.put("extra", "{\"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("shun launch s " + s);
        log.info("shun launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("shun launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("shun launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("shun launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("codeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("shun launch return null");
        return null;
    }


    public PayUrl jjpayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String, Object> business = new TreeMap<>();
        business.put("service", "service.ffff.pay");
        business.put("merchant_id", platMer.getMerKey());
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        business.put("request_time", simpleDateFormat.format(new Date()));
        business.put("nonce_str", UUID.randomUUID().toString().replaceAll("-", ""));
        business.put("version", "V1.0");
//        business.put("sign_type", "MD5");


        Map<String, Object> data = new TreeMap<>();
        data.put("order_no", platMerOrderParam.getOrderId());
        DecimalFormat df = new DecimalFormat("0.00");
        data.put("amount", df.format(platMerOrderParam.getAmount()));
        data.put("notify_url", channel.getNotifyUrl());
        data.put("return_url", channel.getNotifyUrl());
        data.put("currency", "CNY");
        data.put("trade_code", platMerBaseCode.getBaseCode());
        data.put("client_ip", "127.0.0.1");
        data.put("terminal_type", "pc");

        Map<String, Object> sort = new TreeMap<>();
        sort.putAll(business);
        sort.putAll(data);
        log.info("sign map {}", sort);

        String s = convertUrlIsEmptyObject(sort, "&", "=") + "&key=" + platMer.getPrivateKey();

        log.error("jjzhifu url md5 {}", s);
        business.put("sign_type", "MD5");
        business.put("sign", SecureUtil.md5(s).toUpperCase());
        business.put("data", data);

        business.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("map {}", business);

        String body = HttpUtil.createPost(channel.getRealUrl()).body(JSONObject.toJSONString(business)).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);

        log.info("result a jjzhifu {}", body);
        if (jsonObject.getInteger("resp_code").intValue() == 1000) {
            log.info("success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_info"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }
        return null;

    }

    public PayUrl facaiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("transactionId", platMerOrderParam.getOrderId());
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("memo", "test");
        map.put("channel", platMerBaseCode.getBaseCode());
        map.put("outMemId", UUID.randomUUID().toString().replaceAll("-", ""));
        map.put("callbackUrl", channel.getNotifyUrl());
        map.put("ip", "127.0.0.1");

        String s = platMer.getPrivateKey() + "&" + convertUrlNotEmpty(map, "&", "=");
        String sign = SecureUtil.md5(s);
        log.info("facai launch s " + s);
        log.info("facai launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("facai launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("facai launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("0").equals(jsonObject.getString("status"))) {
            log.info("facai launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("urls").getString("orderUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("facai launch return null");
        return null;
    }

    public PayUrl rrfUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("pay_memberid", platMer.getMerKey());
        map.put("pay_orderid", platMerOrderParam.getOrderId());
        map.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        map.put("pay_bankcode", platMerBaseCode.getBaseCode());
        map.put("pay_notifyurl", channel.getNotifyUrl());
        map.put("pay_callbackurl", channel.getNotifyUrl());
        map.put("pay_amount", (platMerOrderParam.getAmount()));

        String s = convertUrlIsEmptyObject(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("rrf launch s " + s);
        log.info("rrf launch md5(s) " + sign);

        map.put("pay_productname", "test");
        map.put("pay_md5sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("rrf launch map " + map);

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "=");
        log.info("rrf {}", url);

        log.info("rrf success");

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl chachaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new HashMap<>();
        map.put("memberid", platMer.getMerKey());
        map.put("orderid", platMerOrderParam.getOrderId());
        map.put("timestamp", System.currentTimeMillis() / 1000);
        map.put("payType", platMerBaseCode.getBaseCode());
        map.put("price", (platMerOrderParam.getAmount()));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("redirectUrl", channel.getNotifyUrl());

        String s = map.get("timestamp") + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toLowerCase();
        log.info("chacha launch s " + s);
        log.info("chacha launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("chacha launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form((map)).execute().body();
        log.info("chacha launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("00").equals(jsonObject.getJSONObject("data").getString("retcode"))) {
            log.info("chacha launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("chacha launch return null");
        return null;
    }

    public PayUrl jsUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("biz_code", platMer.getMerKey());
        map.put("biz_order_no", platMerOrderParam.getOrderId());
        map.put("notify_url", channel.getNotifyUrl());
        map.put("order_amount", String.valueOf(platMerOrderParam.getAmount().multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)).intValue()));
        map.put("product_code", platMerBaseCode.getBaseCode());
        map.put("key", platMer.getPrivateKey());

        String s = convertUrlNotEmpty(map, "&", "=");

        String sign = SecureUtil.md5(s);
        log.info("js launch s " + s);
        log.info("js launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        map.remove("key");

        log.info("js launch map " + map);

        log.info("json {}", JSONObject.toJSONString(map));

        String body = HttpUtil.createPost(channel.getCreateUrl()).form((map)).execute().body();

        log.info("js launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("0").equals(jsonObject.getString("result"))) {
            log.info("js launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("js launch return null");
        return null;
    }

    public PayUrl huanyuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("orderNo", platMerOrderParam.getOrderId());
        map.put("appId", platMer.getMerKey());
        DecimalFormat df = new DecimalFormat("0.00");
        map.put("money", df.format(platMerOrderParam.getAmount()));
        map.put("returnUrl", channel.getNotifyUrl());
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("productName", "pay");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s);
        log.info("huanyu launch s " + s);
        log.info("huanyu launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("huanyu launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("huanyu launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("0").equals(jsonObject.getString("code"))) {
            log.info("huanyu launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("obj"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("huanyu launch return null");
        return null;
    }

    public PayUrl dahengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return juziPayUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl fajiaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("appid", platMer.getMerKey());
        map.put("out_order_no", platMerOrderParam.getOrderId());
        DecimalFormat df = new DecimalFormat("0.00");
        map.put("amount", df.format(platMerOrderParam.getAmount()));
        map.put("pay_code", platMerBaseCode.getBaseCode());
        map.put("notify_url", channel.getNotifyUrl());
        map.put("return_url", channel.getNotifyUrl());

        String s = convertUrlNotEmpty(map, "&", "=") + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s);
        log.info("fajia launch s " + s);
        log.info("fajia launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("fajia launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("fajia launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("0").equals(jsonObject.getString("code"))) {
            log.info("fajia launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("fajia launch return null");
        return null;
    }

    public PayUrl fajiaOrgUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        return pfpayUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl haitunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new HashMap<>();
        map.put("uid", platMer.getMerKey());
        map.put("num", platMerOrderParam.getOrderId());

        DecimalFormat df = new DecimalFormat("0.00");
//        map.put("money", platMerOrderParam.getAmount().multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)));
        map.put("money", df.format(platMerOrderParam.getAmount()));
        map.put("return_type", "");

        String s = platMer.getPrivateKey() + map.get("num") + map.get("money") + map.get("uid");

        String sign = SecureUtil.md5(s);
        log.info("haitun launch s " + s);
        log.info("haitun launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        map.put("callback_url", channel.getNotifyUrl());
        map.put("return_url", channel.getNotifyUrl());

        log.info("haitun launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("haitun launch body {}", body);
//        JSONObject jsonObject = JSONObject.parseObject(body);
//        if (("1").equals(jsonObject.getString("code"))) {
//            log.info("haitun launch success");
//            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("msg").getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
//        }

        return new PayUrl(1, channel.getChannelCode(), body, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

    }

    public PayUrl hongyunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("merchantID", platMer.getMerKey());
        map.put("merchantOrderCode", platMerOrderParam.getOrderId());
//        DecimalFormat df = new DecimalFormat("0.00");
//        map.put("totalMoney", df.format(platMerOrderParam.getAmount()));
        map.put("totalMoney", platMerOrderParam.getAmount());
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("returnUrl", channel.getNotifyUrl());
        map.put("codeReturnUrl", "http://ww.baidu.com");

        String s = convertUrlNotEmpty(map, "&", "=") + "&MD5Str=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("hongyun launch s " + s);
        log.info("hongyun launch md5(s) " + sign);

        map.put("appSecret", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        map.put("returnFormat", "json");

        log.info("hongyun launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("hongyun launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("true".equals(jsonObject.getString("success"))) {
            log.info("hongyun launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("QrCode"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("hongyun error");
        return null;
    }

    public PayUrl haofuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, String> map = new TreeMap<>();
        map.put("partner", platMer.getMerKey());
        map.put("amount", String.valueOf(platMerOrderParam.getAmount()));
        map.put("request_time", String.valueOf(System.currentTimeMillis() / 1000));
        map.put("trade_no", platMerOrderParam.getOrderId());
        if (!platMerOrderParam.getSaveWayCode().equals("zfb2bank")) {
            map.put("pay_type", platMerBaseCode.getBaseCode());
        }
        map.put("notify_url", channel.getNotifyUrl());
        map.put("callback_url", channel.getNotifyUrl());

        String s = convertUrl(map, "&", "=") + "&" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toLowerCase();
        log.info("haofu launch s " + s);
        log.info("haofu launch md5(s) " + sign);

        map.put("sign", sign);
        map.put("method", "post");
        if (platMerOrderParam.getSaveWayCode().equals("zfb2bank")) {
            map.put(Epay.REAL_URL, channel.getRealUrl() + "/payCenter/unionqrpay");
        } else {
            map.put(Epay.REAL_URL, channel.getRealUrl() + "/payCenter/gatewaypay");
        }
        log.info("haofu launch map " + map);


        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrl(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl huanqiuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("merchantNo", platMer.getMerKey());
        map.put("nonce", UUID.randomUUID().toString().replaceAll("-", ""));
        map.put("timestamp", System.currentTimeMillis() + "");

        String s = convertUrlIsEmptyObject(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        log.info("s {}", s);

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("sign {}", sign);
        map.put("sign", sign);
        map.put("Key", "");
        map.put("token", "");
        log.info("map {}", map);


        String url = channel.getRealUrl() + "api/v1/getAccessToken/merchant";
        log.info("huanqiu url {}", url);
        map.put(Epay.REAL_URL, url);
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("huanqiu body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        String acessToken = "";
        if (jsonObject.getBoolean("success")) {
            acessToken = jsonObject.getJSONObject("value").getString("accessToken");
        }

        Map<String, String> param = new HashMap<>();
        param.put("outTradeNo", platMerOrderParam.getOrderId());
        param.put("money", String.valueOf(platMerOrderParam.getAmount().multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)).intValue()));
        param.put("type", platMerBaseCode.getBaseCode());
        param.put("body", "test");
        param.put("detail", "test");
        param.put("notifyUrl", channel.getNotifyUrl());
        param.put("productId", "123");
        param.put("successUrl", channel.getNotifyUrl());
        param.put("callbackSuccessUrl", channel.getNotifyUrl());

        Map<String, Object> map1 = new LinkedHashMap<>();
        map1.put("accessToken", acessToken);
        map1.put("param", param);

        String payUrl = channel.getRealUrl() + "api/v1/order/alipayScan";
        log.info("huanqiu launch map1 " + map1);

        String json = JSONObject.toJSONString(map1);
        log.info("JSONObject.toJSONString(map1) {}", json);
        String body1 = HttpRequest.post(payUrl).header("Content-Type", "application/json").body(json).execute().body();
//        String body1 = HttpUtil.createPost(channel.getCreateUrl()).body(JSONObject.toJSONString(map1)).execute().body();

        log.info("huanqiu launch body1 {}", body1);
        JSONObject jsonObject1 = JSONObject.parseObject(body1);
        if (jsonObject1.getBoolean("success")) {
            log.info("huanqiu launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject1.getString("value"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("huanqiu error");
        return null;
    }

    public PayUrl shengrongUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("price", platMerOrderParam.getAmount());
        map.put("out_order_id", platMerOrderParam.getOrderId());
        map.put("type", platMerBaseCode.getBaseCode());
        map.put("notifyurl", channel.getNotifyUrl());
        map.put("returnurl", channel.getNotifyUrl());
        map.put("extend", "1");

        StringBuilder stringBuilder = new StringBuilder("");
        for (Map.Entry<String, Object> stringObjectEntry : map.entrySet()) {
            stringBuilder.append(stringObjectEntry.getValue());
        }

        log.info("shengrong sb {}", stringBuilder);

        String sign = SecureUtil.md5(SecureUtil.md5(stringBuilder.toString()) + platMer.getPrivateKey());

        log.info("shengrong launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        map.put("app_id", platMer.getMerKey());
        map.put("format", "json");

        log.info("shengrong launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("shengrong launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getInteger("code") == 1) {
            log.info("shengrong launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("qrcodeurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("shengrong error");
        return null;
    }

    public PayUrl liandaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return binliUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl wanmeiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("DOMAINNAME", "mp.perfect2pay.com");
        map.put("CLOUDID", platMer.getMerKey());
        map.put("ACCOUNTINFO", platMerOrderParam.getOrderId());
        map.put("PAYAMOUNT", platMerOrderParam.getAmount());
        map.put("CALLBACKURL", channel.getNotifyUrl());
        map.put("CALLBACKPAGEURL", channel.getNotifyUrl());
        map.put("USERCODE", platMerBaseCode.getBaseCode());

        String s = SecureUtil.md5(SecureUtil.md5(MapUtil.getStr(map, "ACCOUNTINFO") + MapUtil.getStr(map, "DOMAINNAME") + MapUtil.getStr(map, "CLOUDID")) + platMer.getPrivateKey());
        log.info("wanmei launch s" + s);

        String sign = s.substring(8, 24);
        log.info("wanmei launch md5(s) " + sign);

        map.put("SIGN", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("wanmei launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("wanmei launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("true".equals(jsonObject.getString("success"))) {
            log.info("shengrong launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("result").getString("pageUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("wanmei error");
        return null;
    }

    public PayUrl juheUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("parter", platMer.getMerKey());
        sortedMap.put("orderid", platMerOrderParam.getOrderId());
        sortedMap.put("type", platMerBaseCode.getBaseCode());
//        sortedMap.put("hrefbackurl", channel.getNotifyUrl());
        sortedMap.put("callbackurl", channel.getNotifyUrl());
        sortedMap.put("value", String.format("%.2f", platMerOrderParam.getAmount()));
        String s = "parter=" + platMer.getMerKey() + "&type=" + platMerBaseCode.getBaseCode() + "&value=" + String.format("%.2f", platMerOrderParam.getAmount()) +
                "&orderid=" + platMerOrderParam.getOrderId() + "&callbackurl=" + channel.getNotifyUrl() + platMer.getPrivateKey();
        log.info("result a qbf {}", s);
        String sign = SecureUtil.md5(s).toLowerCase();

        String createUrl = channel.getCreateUrl();
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("url {}", createUrl + "?" + convertUrl(sortedMap, "&", "=") + "&sign=" + sign);

        log.info("success");
        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + convertUrl(sortedMap, "&", "=") + "&sign=" + sign, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl jiuxuanUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map sortedMap = new TreeMap();
        sortedMap.put("user_account", platMer.getMerKey());
        sortedMap.put("out_trade_no", platMerOrderParam.getOrderId());
        sortedMap.put("total_fee", platMerOrderParam.getAmount().toString());
        sortedMap.put("trade_time", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyyMMddHHmmss"));
        sortedMap.put("payment_type", platMerBaseCode.getBaseCode());
//        sortedMap.put("pay_bankcode", platMerBaseCode.getBankCode());
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("return_url", channel.getNotifyUrl());
        sortedMap.put("body", "test");
//        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());

        String s = convertUrl(sortedMap, "&", "=");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();
        log.error("sign is error {}", s + "&key=" + platMer.getPrivateKey());
        s = convertUrl(sortedMap, "&", "=") + "&sign=" + sign;
        String createUrl = channel.getCreateUrl();

        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }


    public PayUrl shejiaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("merchantNum", platMer.getMerKey());
        sortedMap.put("orderNo", platMerOrderParam.getOrderId());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("payType", platMerBaseCode.getBaseCode());

        String signUrl = platMer.getMerKey() + platMerOrderParam.getOrderId() + decimalFormat.format(platMerOrderParam.getAmount()) + channel.getNotifyUrl() + platMer.getPrivateKey();
        sortedMap.put("sign", SecureUtil.md5(signUrl).toUpperCase());

        sortedMap.put("returnUrl", "http://www.baidu.com");
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("yi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("yi launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("yi launch error");
        return null;
    }

    public PayUrl dxerUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("merchant_id", platMer.getMerKey());
        map.put("version", "V2.0");
        map.put("pay_type", platMerBaseCode.getBaseCode());
        map.put("device_type", "wap");
        map.put("request_time", DateUtil.format(new Date(), "yyyyMMddHHmmss"));
        map.put("nonce_str", UUID.randomUUID().toString().replaceAll("-", ""));
        map.put("pay_ip", "127.0.0.1");
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        map.put("notify_url", channel.getNotifyUrl());
        map.put("return_url", channel.getNotifyUrl());
//        map.put("commodityBody", "商品信息");

        String s = convertUrlNotEmpty(map, "&", "=") + platMer.getPrivateKey();
        log.info("dxer launch s" + s);

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("dxer launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("dxer launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("dxer launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("success".equals(jsonObject.getString("status"))) {
            log.info("dxer launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("dxer error");
        return null;
    }

    public PayUrl seboUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("mer_no", platMer.getMerKey());
        map.put("mode_type", platMerBaseCode.getBaseCode());
        map.put("total_fee", new DecimalFormat("0").format(platMerOrderParam.getAmount()));
        map.put("ordersn", platMerOrderParam.getOrderId());
        map.put("subject", "test");
        map.put("client_ip", "127.0.0.1");
        map.put("notify_url", channel.getNotifyUrl());
        map.put("return_url", channel.getNotifyUrl());

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        log.info("sebo launch s" + s);

        String sign = SecureUtil.md5(s);
        log.info("sebo launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("sebo launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("sebo launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("10000".equals(jsonObject.getString("code"))) {
            log.info("sebo launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("cont").getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("sebo error");
        return null;
    }

    public PayUrl haitun2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("order_num", platMerOrderParam.getOrderId());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        map.put("pay_amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        map.put("return_url", channel.getNotifyUrl());
        map.put("notify_url", channel.getNotifyUrl());
        map.put("note", "test");
        map.put("app_tm", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));

        String s = convertUrlNotEmpty(map, "&", "=") + "&" + platMer.getPrivateKey();

        log.info("haitun2 launch s" + s);

        String sign = SecureUtil.md5(s).toLowerCase();
        log.info("haitun2 launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        map.put("app_key", platMer.getMerKey());
        map.put("request_ip", "127.0.0.1");

        log.info("haitun2 launch map " + map);

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "=");
        log.info("rrf {}", url);

        log.info("rrf success");

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl qianjinfuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("merchantId", platMer.getMerKey());
        map.put("tradeNo", platMerOrderParam.getOrderId());
        map.put("amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        map.put("applyDate", DateUtil.format(new Date(), "yyyy-MM-dd hh:mm:ss"));
        map.put("channelType", platMerBaseCode.getBaseCode());
        map.put("notifyUrl", channel.getNotifyUrl());

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        log.info("qianjinfu launch s" + s);

        String sign = SecureUtil.md5(s);
        log.info("qianjinfu launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("qianjinfu launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("qianjinfu launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("1".equals(jsonObject.getString("code"))) {
            log.info("qianjinfu launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("qianjinfu error");
        return null;
    }

    public PayUrl suibianUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("amount", new DecimalFormat("0").format(platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("attach", "test");
        map.put("client_ip", "127.0.0.1");
        map.put("create_time", System.currentTimeMillis() / 1000);
        map.put("name", "test");
        map.put("notify_url", channel.getNotifyUrl());
        map.put("order_channel", platMerBaseCode.getBaseCode());
        map.put("ran_str", UUID.randomUUID().toString().replaceAll("-", ""));
        map.put("return_url", channel.getNotifyUrl());
        map.put("site_name", "tets");
        map.put("tenant_id", platMer.getMerKey());
        map.put("tenant_order_id", platMerOrderParam.getOrderId());

        String s = convertUrlNotEmpty(map, "&", "=") + "&secret=" + platMer.getPrivateKey();

        log.info("suibian launch s" + s);

        String sign = SecureUtil.md5(s);
        log.info("suibian launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("suibian launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("suibian launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("0".equals(jsonObject.getString("code"))) {
            log.info("suibian launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("suibian error");
        return null;
    }

    public PayUrl wuyueUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("merchant_no", platMer.getMerKey());
        map.put("out_order_no", platMerOrderParam.getOrderId());
        map.put("amount", platMerOrderParam.getAmount().intValue() + "");
        map.put("pay_type", platMerBaseCode.getBaseCode());
        map.put("notify_url", channel.getNotifyUrl());

        String s = "";
        for (Map.Entry<String, Object> stringObjectEntry : map.entrySet()) {
            s += stringObjectEntry.getValue();
        }
        s += platMer.getPrivateKey();

        log.info("wuyue launch s" + s);

        String sign = SecureUtil.md5(s);
        log.info("wuyue launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("wuyue launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("wuyue launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("1".equals(jsonObject.getString("code"))) {
            log.info("wuyue launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("wuyue error");
        return null;
    }


    public PayUrl payOneOkUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("orderMoney", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        map.put("mcCode", platMer.getMerKey());
        map.put("channelId", platMerBaseCode.getBaseCode());
        map.put("mcOrderId", platMerOrderParam.getOrderId());
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("returnUrl", channel.getNotifyUrl());

        String s = convertUrlIsEmptyObject(map, "&", "=") + platMer.getPrivateKey();

        log.info("kaer launch s" + s);

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("kaer launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("kaer launch map " + map);

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "=");
        log.info("rrf {}", url);

        log.info("rrf success");

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl OTCXUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("userId", platMer.getMerKey());
        map.put("tradeAmt", platMerOrderParam.getAmount());
        map.put("orderRemark", platMerOrderParam.getOrderId());
        map.put("nbNotifyUrl", channel.getNotifyUrl());
        map.put("receipt", "[1]");

        String s = platMer.getPrivateKey() + map.get("nbNotifyUrl").toString() + map.get("orderRemark").toString() + map.get("receipt").toString() +
                map.get("tradeAmt").toString() + map.get("userId");

        log.info("OTCX launch s" + s);

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("OTCX launch md5(s) " + sign);

        map.put("hmac", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("OTCX launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("OTCX launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("000".equals(jsonObject.getString("code"))) {
            log.info("OTCX launch success");

            String url = jsonObject.getJSONObject("obj").getString("h5_url") + "?id=" + jsonObject.getJSONObject("obj").getString("id") + "&userId=" + platMer.getMerKey();
            log.info("url {}", url);
            return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("OTCX error");
        return null;
    }

    public PayUrl dingshunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        map.put("client_ip", "127.0.0.1");
        map.put("goods_name", "test");
        map.put("is_form", "1");
        map.put("merchant_id", platMer.getMerKey());
        map.put("notify_url", channel.getNotifyUrl());
        map.put("out_trade_id", platMerOrderParam.getOrderId());
        map.put("product_id", platMerBaseCode.getBaseCode());
        map.put("return_url", channel.getNotifyUrl());

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        log.info("dingshun launch s" + s);

        String sign = SecureUtil.md5(s).toLowerCase();
        log.info("dingshun launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("dingshun launch map " + map);

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "=");
        log.info("dingshun url {}", url);

        log.info("dingshun success");

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl sljUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getNotifyUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());

        String s = convertUrl(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("pay_md5sign", sign);
        sortedMap.put("pay_productname", "test");

        log.info("slj launch map " + sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("slj launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("0000".equals(jsonObject.getString("code"))) {
            log.info("slj launch success");

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("slj error");
        return null;
    }

    public PayUrl hookUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", "8c1cddbbdfba48eeb26468eb03bfd66e");
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("param1", "10");
        map.put("extra", "{\"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("hook launch s " + s);
        log.info("hook launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("hook launch map " + map);

//        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "=");
//        log.info("yuansheng url {}", url);
//
//        log.info("yuansheng success");
//
//        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("hook launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("hook launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("payurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hook launch return null");
        return null;
    }

    public PayUrl yuanshengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getNotifyUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());

        String s = convertUrl(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("pay_md5sign", sign);
        sortedMap.put("pay_productname", "test");

        log.info("yuansheng launch map " + sortedMap);

        log.info("yuansheng launch map " + sortedMap);

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(sortedMap, "&", "=");
        log.info("yuansheng url {}", url);

        log.info("yuansheng success");

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl julianUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("merchNo", platMer.getMerKey());
        sortedMap.put("merchOrderNum", platMerOrderParam.getOrderId());
        sortedMap.put("orderAmount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))).toString());
        sortedMap.put("orderFoodName", "test");
        sortedMap.put("netwayCode", platMerBaseCode.getBaseCode());
        sortedMap.put("requestIp", "127.0.0.1");
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("returnUrl", channel.getNotifyUrl());


        String s = convertUrl(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();

        log.info("s {}", s);
        String sign = SecureUtil.md5(s).toUpperCase();

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("returnUrl", channel.getNotifyUrl());


        log.info("julian launch map " + sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("julian launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("00".equals(jsonObject.getString("flag"))) {
            log.info("julian launch success");

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("julian error");
        return null;
    }

    public PayUrl kubeiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getNotifyUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());

        String s = convertUrl(sortedMap, "&", "=") + "&" + platMer.getPrivateKey();
        log.info("s {}", s);

        String sign = SecureUtil.md5(s).toUpperCase();

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("pay_md5sign", sign);
        sortedMap.put("pay_productname", "test");

        log.info("yuansheng launch map " + sortedMap);

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(sortedMap, "&", "=");
        log.info("yuansheng url {}", url);

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl baichuanUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("customer_id", platMer.getMerKey());
        sortedMap.put("out_order_id", platMerOrderParam.getOrderId());
        sortedMap.put("pay_type", platMerBaseCode.getBaseCode());
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("return_url", channel.getNotifyUrl());
        sortedMap.put("money", platMerOrderParam.getAmount().toString());
        sortedMap.put("from_ip", "127.0.0.1");

        String s = convertUrl(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        log.info(" baichuan s {}", s);

        String sign = SecureUtil.md5(s).toUpperCase();

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);
        log.info(" baichuan launch map " + sortedMap);

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(sortedMap, "&", "=");
        log.info("baichuan url {}", url);

        log.info("baichuan success");

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl kubei2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("mno", platMer.getMerKey());
        sortedMap.put("orderno", platMerOrderParam.getOrderId());
        sortedMap.put("amount", platMerOrderParam.getAmount().multiply(new BigDecimal(100)));
        sortedMap.put("pt_id", platMerBaseCode.getBaseCode());
        sortedMap.put("device", "1");
        sortedMap.put("time", DateUtil.format(new Date(), "YYYY-MM-DD HH:II:SS"));

        String s = convertUrl(sortedMap, "&", "=");

        log.info("kubei2 s {}", s);
        String sign = SecureUtil.md5(s).toUpperCase();

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);

        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("async_notify_url", channel.getNotifyUrl());

        log.info("kubei2 launch map " + sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("kubei2 launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("00".equals(jsonObject.getString("flag"))) {
            log.info("kubei2 launch success");

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("kubei2 error");
        return null;
    }

    public PayUrl stormUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("app_id", platMer.getMerKey());
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("method", platMerBaseCode.getBaseCode());
        sortedMap.put("timestamp", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("out_trade_no", platMerOrderParam.getOrderId());
        sortedMap.put("total_amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));

        sortedMap.put("subject", "test");

        log.info("s1 {}", "timestamp=" + sortedMap.get("timestamp").toString() + "&public_key=" + platMer.getPublicKey() + "&private_key=" + platMer.getPrivateKey());
        String s1 = SecureUtil.md5("timestamp=" + sortedMap.get("timestamp").toString() + "&public_key=" + platMer.getPublicKey() + "&private_key=" + platMer.getPrivateKey());

        log.info("s2 {}", "app_id=" + sortedMap.get("app_id").toString() + "&method=" + sortedMap.get("method").toString() + "&out_trade_no=" +
                sortedMap.get("out_trade_no").toString() + "&total_amount=" + sortedMap.get("total_amount") + "&sign=" + s1);

        String s2 = SecureUtil.md5("app_id=" + sortedMap.get("app_id").toString() + "&method=" + sortedMap.get("method").toString() + "&out_trade_no=" +
                sortedMap.get("out_trade_no").toString() + "&total_amount=" + sortedMap.get("total_amount") + "&sign=" + s1);

        log.info("stormUrl s2 {}", s2);
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", s2);

        log.info("stormUrl launch map " + sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("stormUrl launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("0".equals(jsonObject.getString("code"))) {
            log.info("stormUrl launch success");

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("stormUrl error");
        return null;
    }

    public PayUrl hengshengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", platMer.getPublicKey());
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", String.valueOf((platMerOrderParam.getAmount().multiply(new BigDecimal(100))).intValue()));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("clientIp", "127.0.0.1");


        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);
        map.put("param1", "");
        map.put("sign", sign);
//        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);
        Map<String, Object> data = new TreeMap();
        data.put("params", JSONObject.toJSONString(map));
        map.put("extra", "{\"openId\":\"d47fc085cce7415a9761852a649d8458\"}");
        String body = HttpRequest.post(channel.getRealUrl()).form(data).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

//        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
//        log.info("jinxin launch body {}", body);
//        JSONObject jsonObject = JSONObject.parseObject(body);
//        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
//            log.info("jinxin launch success");
//            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("codeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
//        }
//
        log.info("jinxin launch return null");
        return null;

    }

    public PayUrl jpUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("customerId", platMer.getMerKey());
        map.put("orderAmount", platMerOrderParam.getAmount());
        map.put("orderCurrency", "CNY");
        map.put("orderNo", platMerOrderParam.getOrderId());
        map.put("pickupUrl", channel.getNotifyUrl());
        map.put("receiveUrl", channel.getNotifyUrl());
        map.put("signType", "MD5");

        String s = map.get("pickupUrl").toString() + map.get("receiveUrl") + map.get("signType") + map.get("orderNo") + map.get("orderAmount") +
                map.get("orderCurrency") + map.get("customerId") + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s);

        log.info("jpUrl launch s " + s);
        log.info("jpUrl launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl() + platMer.getMerKey());
        log.info("jpUrl map " + map);

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "=");
        log.info("jpUrl url {}", url);

        log.info("jpUrl success");

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl fcUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("appid", platMer.getMerKey());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("callback_url", channel.getNotifyUrl());
        map.put("success_url", channel.getNotifyUrl());
        map.put("error_url", channel.getNotifyUrl());
        map.put("out_uid", "15017399440");
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("version", "v1.1");
        log.info(" pilin map " + map);

        StringBuilder s = new StringBuilder("");
        for (String key : map.keySet()) {
            if (null != map.get(key) && !"".equals(map.get(key))) {
                s.append(key).append("=").append(map.get(key)).append("&");
            }
        }
        s.append("key").append("=").append(platMer.getPrivateKey());
        log.info("feichi s " + s);

        String md5Str = SecureUtil.md5(s.toString()).toUpperCase();
        log.info(" feichi md5Str " + md5Str);

        map.put("sign", md5Str);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("feichi pilin map " + map);

        String body = HttpRequest.post(channel.getRealUrl()).form(map).execute().body();
        log.info("feichi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("feichi launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }

    public PayUrl kubeiNewUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws Exception {

        Map<String, Object> map = new TreeMap<>();
        map.put("mno", platMer.getMerKey());
        map.put("orderno", platMerOrderParam.getOrderId());
        map.put("pt_id", platMerBaseCode.getBaseCode());
        map.put("device", "1");
        map.put("time", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));

        map.put("amount", String.valueOf(platMerOrderParam.getAmount().multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue()));

        String s = convertUrlNotEmpty(map, "&", "=");
        log.error(" date sign url {}", s);
//        byte[] aByte = HexUtil.decodeHex(platMer.getPrivateKey().replaceAll(" ","+"));
//        RSA rsa = new RSA(platMer.getPrivateKey(),null);

//        byte[] encrypt = rsa.encrypt(StrUtil.bytes(s, CharsetUtil.CHARSET_UTF_8), KeyType.PrivateKey);
        map.put("sign", Base64.encodeBase64String(RSAUtils.encryptByPrivateKey(s.getBytes("UTF-8"), platMer.getPrivateKey())));
        map.put("notify_url", "http://wwww.baidu.com");
        map.put("async_notify_url", channel.getNotifyUrl());


        AES aes = SecureUtil.aes(platMer.getWithdrawKey().replaceAll(" ", "+").getBytes());
        byte[] result = aes.encrypt(JSON.toJSONBytes(map));

        Map<String, Object> dataContent = new TreeMap<>();
        dataContent.put("mno", platMer.getMerKey());
        log.error("result {}", Base64.encodeBase64String(result));
        dataContent.put("content", Base64.encodeBase64String(result));

        dataContent.put(Epay.REAL_URL, channel.getRealUrl());

        String body = HttpRequest.post(channel.getCreateUrl()).form(dataContent).execute().body();
        log.info("kubeiUrl launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("success").equals(jsonObject.getString("code"))) {
            log.info("feichi launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        return null;
    }

    public PayUrl shoudaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return rrfUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl fchUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());
        if (channel.getChannelCode().equals("wenxinpay")) {
            sortedMap.put("pay_is_form", "1");
        }
        String s = convertUrl(sortedMap, "&", "=");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        s = s + "&pay_productname=test&pay_md5sign=" + sign;
        String createUrl = channel.getCreateUrl();

        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl heshunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, String> map = new LinkedHashMap<>();
        map.put("merchantId", platMer.getMerKey());
        map.put("userId", UUID.randomUUID().toString().replace("-", ""));
        map.put("subOrderNo", platMerOrderParam.getOrderId());
        map.put("productId", "");
        map.put("money", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        map.put("type", platMerBaseCode.getBaseCode());
        map.put("userBankCardId", "");
        map.put("bankType", "");
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("returnUrl", channel.getNotifyUrl());

        String s = convertUrlIsEmpty(map, "&", "=") + platMer.getPrivateKey();
        log.info("heshunUrl s {}", s);

        String sign = SecureUtil.md5(s);
        log.info("heshunUrl sign {}", sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl() + platMer.getMerKey());
        log.info("heshunUrl map " + map);

        String url = channel.getCreateUrl() + "?" + convertUrlIsEmpty(map, "&", "=");
        log.info("heshunUrl url {}", url);

        log.info("heshunUrl success");

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl kuaixunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("merchant", platMer.getMerKey());
        DecimalFormat df = new DecimalFormat("0.00");
        map.put("amount", df.format(platMerOrderParam.getAmount()));
        map.put("pay_code", platMerBaseCode.getBaseCode());
        map.put("order_no", platMerOrderParam.getOrderId());
        map.put("notify_url", channel.getNotifyUrl());
        map.put("return_url", channel.getNotifyUrl());
        map.put("cuid", RandomUtil.randomNumbers(5));
        map.put("order_time", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toLowerCase();
        log.info("fajia launch s " + s);
        log.info("fajia launch md5(s) " + sign);

        map.put("sign", sign);

        log.info("fajia launch map " + map);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jpUrl map " + map);

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "=");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public static void main(String args[]) throws Exception {

        System.out.println(Base64.encodeBase64(RSAUtils.encryptByPrivateKey("amount=4000&device=1&mno=A200423052458119&orderno=jf239606792068268032&pt_id=1&time=2020-04-24 21:21:04".getBytes(), "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAKjdNjlw/TCo2rvr\n" +
                "GhIJt2WuS7raOuHucij7HN8iw4SxhcyN46rBCBgvsCEY7r34RwoH32+SxXfZC0K6" +
                "tqDqETnCUdvKaj5Z9w8mLk/7J3QpDD8BQCtm+D81Un4OqUvdLBXc8A36LHcJde0Q" +
                "Aw5GhDg2dhkPTUKbIG/zC2Vr0mOdAgMBAAECgYEAl6zq8bltknF412YbKqyTkL93" +
                "wkQWs60r2WeEzWA6YkvaNJwWLN/p11+uQmxUtUn29SmRJnSc7kOD+9IeDHdyNAuv" +
                "8e9LespzApnGD4nra8xFjxw1E86/zAbjiqwwz2fCYxNfpx/b/z/ofjfelg1G4iqd" +
                "boWC6APiTEW5uiQcmQECQQDSSWH7AGSWEOivQgmBUQc//Uc/ekZH4xj9b5LYmRS3" +
                "wA/W8TMTnY3I6H+8zdZoMSvgkYYfV0zNvemFFPhZniHhAkEAzZKhzj3ozcxC4qH0" +
                "ze6CucEeAHcjF+rbi58I9WOr+u0B0JRkj8JB9eseS8SQ0hUoWmH0kugHSjsHMMP0" +
                "KjBxPQJBAJJ/jyQHZQvq4b/fGLIfmhZpRC6j57yDKNC+3yXIl9dflWlgBf5fX/yc" +
                "hQkquXlC8Fd16mOBNT+MU9hkAJSmhuECQQCIu9ph+u3JTO7EHaNeAiHzec8B0jyG" +
                "YRGMiciEp7oxmclWOg21TSlgb/XjwafuBGKl03fA6xJGPoLm3b+e/D+lAkAdUs5W" +
                "hxGHF3bK1CTka/D+D9zOfwTGyR9vMtKWu7ez/vRV9I5p9VdcBJJv/6TOXQy+gPJG\n" +
                "qNqPz1rhNMxfcu7j")));
    }

    public PayUrl dysfUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("version", "3.0");
        map.put("method", "Gt.online.interface");
        map.put("partner", platMer.getMerKey());
        map.put("banktype", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("paymoney", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("ordernumber", platMerOrderParam.getOrderId());
        map.put("callbackurl", channel.getNotifyUrl());

        String s = convertUrlIsEmptyObject(map, "&", "=") + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toLowerCase();
        map.put("sign", sign);
        map.put("notreturnpage", true);
        log.info("hongYi s " + s);
        log.info("hongYi sign " + sign);

        map.put("hrefbackurl", channel.getNotifyUrl());
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("hongYi map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getInteger("code").intValue() == 1000) {
            log.info("hongYi success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hongYi return null");
        return null;
    }

    public PayUrl wantengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return rrfUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl siUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return caiyingNewUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl mnashangUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("merchantCode", platMer.getMerKey());
        map.put("merchantOrderId", platMerOrderParam.getOrderId());
        map.put("paymentTypeCode", platMerBaseCode.getBaseCode());
        map.put("amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        map.put("successUrl", channel.getNotifyUrl());
        map.put("merchantMemberId", UUID.randomUUID().toString().replace("-", ""));
        map.put("merchantMemberIp", "127.0.0.1");

        String s = convertUrlIsEmptyObject(map, "|", "=") + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);

        map.put("sign", sign);
        log.info("mnashangUrl s " + s);
        log.info("mnashangUrl sign " + sign);

        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("mnashangUrl map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("mnashangUrl body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("true".equals(jsonObject.getString("result"))) {
            log.info("mnashangUrl success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("httpUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("mnashangUrl return null");
        return null;
    }

    public PayUrl knUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("merchantCode", platMer.getMerKey());
        map.put("merchantTradeNo", platMerOrderParam.getOrderId());
        map.put("userId", UUID.randomUUID().toString().replace("-", ""));
        map.put("amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        map.put("notifyUrl", channel.getNotifyUrl());
//        map.put("returnUrl", channel.getNotifyUrl());
        map.put("terminalType", "1");
        map.put("channel", platMerBaseCode.getBaseCode());
//        map.put("extendedAttrData", "json");
        String sign = null;
        try {
            log.error("sign private" + platMer.getPrivateKey());
            sign = this.sign(map, platMer.getPrivateKey().replaceAll(" ", ""));
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        map.put("sign", sign);
        String data = JSON.toJSONString(map);

        String cryptData = null;
        try {
            cryptData = this.encrypt(data, platMer.getPublicKey().replaceAll(" ", ""));
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        Map<String, Object> requestMap = new HashMap<String, Object>();
        requestMap.put("merchantCode", platMer.getMerKey());
        requestMap.put("content", cryptData);
        requestMap.put(Epay.REAL_URL, channel.getRealUrl());

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(requestMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        String content = jsonObject.getJSONObject("data").getString("content");
        log.error("content ===" + content);
        try {
            String r = decrypt(content, platMer.getPrivateKey().replace(" ", ""));
            log.error("result", r);
            JSONObject result = JSONObject.parseObject(r);
            return new PayUrl(1, channel.getChannelCode(), result.getString("payUrl").replaceAll("hsysf.hzfhhcc.com", "45.113.200.235:90").replaceAll("https", "http"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            log.error("ex system", e);

        }

        log.info("knUrl return null");
        return null;
    }

    private String decrypt(String crypt, String myPrivateKey) throws Exception {

        myPrivateKey = myPrivateKey.replaceAll("\\s*|\t|\r|\n", "");
        byte[] keyBytes = java.util.Base64.getDecoder().decode(myPrivateKey.getBytes("UTF-8"));
        PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        PrivateKey key = keyFactory.generatePrivate(spec);

        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.DECRYPT_MODE, key);
        byte[] dataBytes = java.util.Base64.getDecoder().decode(crypt);
        int inputLen = dataBytes.length;
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        int offset = 0;
        byte[] cache;
        int i = 0;
        // 对数据分段解密
        while (inputLen - offset > 0) {
            if (inputLen - offset > MAX_DECRYPT_BLOCK) {
                cache = cipher.doFinal(dataBytes, offset, MAX_DECRYPT_BLOCK);
            } else {
                cache = cipher.doFinal(dataBytes, offset, inputLen - offset);
            }
            out.write(cache, 0, cache.length);
            i++;
            offset = i * MAX_DECRYPT_BLOCK;
        }
        byte[] decryptedData = out.toByteArray();
        out.close();
        // 解密后的内容
        return new String(decryptedData, "UTF-8");


    }

    public PayUrl abUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws Exception {
        Map<String, Object> map = new TreeMap<>();
        map.put("cmd", platMerBaseCode.getBaseCode());
        map.put("version", "2.0");
        map.put("appid", platMer.getMerKey());
        map.put("userid", platMer.getWithdrawKey());
        map.put("apporderid", platMerOrderParam.getOrderId());
        map.put("ordertime", DateUtil.format(new Date(), "yyyyMMddHHmmss"));
        map.put("orderbody", (int) ((Math.random() * 9 + 1) * 10000));

        map.put("amount", platMerOrderParam.getAmount());
        map.put("notifyurl", channel.getNotifyUrl());
        map.put("custip", "127.0.0.1");


//        map.put("cmd",  platMerBaseCode.getBaseCode());
//        map.put("version", "2.0");
//        map.put("appid", platMer.getMerKey());
//        map.put("userid", "CAT201911091955560003");
//        map.put("apporderid", platMerOrderParam.getOrderId());
//        map.put("ordertime", DateUtil.format(new Date(), "yyyyMMddHHmmss"));
//        map.put("orderbody", "222.65.183.51");
//        map.put("orderdesc", "test");
//        map.put("amount", platMerOrderParam.getAmount());
//        map.put("notifyurl", channel.getNotifyUrl());
//        map.put("front_skip_url", channel.getNotifyUrl());

        String s = convertUrlIsEmptyObject(map, "&", "=");
        log.info("s {}", s);

        log.info("platMer.getPrivateKey() {}", platMer.getPrivateKey());
        String sign = getKeyedDigestUTF8(s, platMer.getPrivateKey());
        log.info("abUrl launch md5(s) " + sign);

        map.put("hmac", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("abUrl map " + map);

//        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "=");
//        log.info("url {}", url);
//
//        log.info("luoyao success");
//        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("knUrl body info data body {}", body);

        Map<String, String> map1 = new HashMap<>();
        List<String> list = Arrays.asList(StringUtils.split(body, "&"));
        for (String s1 : list) {
            List<String> keyMapList = Arrays.asList(StringUtils.split(s1, "="));
            map1.put(keyMapList.get(0), keyMapList.get(1));
        }
        log.info("rs map {}", map1);

        if ("3".equals(map1.get("errcode"))) {
            log.info("knUrl success");
            String payUrl = this.decryptDataUTF8(map1.get("payurl"), platMer.getPublicKey());
            log.info("payUrl {}", payUrl);

            return new PayUrl(1, channel.getChannelCode(), payUrl, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("knUrl return null");
        return null;
    }

    public static String decryptDataUTF8(String decryptdata, String decryptkey) throws Exception {
        DESPlus desPlus = new DESPlus(decryptkey);
        return desPlus.decryptUTF(decryptdata);
    }

    static class DESPlus {
        private final String strDefaultKey = "speed";
        private Cipher encryptCipher = null;
        private Cipher decryptCipher = null;

        /**
         * <p> byteÊý×é×ª»»Îª±íÊ¾16½øÖÆÖµµÄ×Ö·û´®£¬ Èç£ºbyte[]{8,18}×ª»»Îª£º0813£¬ ºÍpublic static byte[] </p>
         * <p> hexStr2ByteArr(String strIn) »¥Îª¿ÉÄæµÄ×ª»»¹ý³Ì</p>
         *
         * @param arrB ÐèÒª×ª»»µÄbyteÊý×é
         * @return ×ª»»ºóµÄ×Ö·û´®
         * @throws Exception ±¾·½·¨²»´¦ÀíÈÎºÎÒì³££¬ËùÓÐÒì³£È«²¿Å×³ö
         */
        public String byteArr2HexStr(byte[] arrB) throws Exception {
            int iLen = arrB.length;
            StringBuffer sb = new StringBuffer(iLen * 2);
            for (int i = 0; i < iLen; i++) {
                int intTmp = arrB[i];
                while (intTmp < 0)
                    intTmp = intTmp + 256;
                if (intTmp < 16)
                    sb.append("0");
                sb.append(Integer.toString(intTmp, 16));
            }
            return sb.toString();
        }

        /**
         * <p> ½«±íÊ¾16½øÖÆÖµµÄ×Ö·û´®×ª»»ÎªbyteÊý×é£¬ ºÍpublic static String byteArr2HexStr(byte[] arrB)»¥Îª¿ÉÄæµÄ×ª»»¹ý³Ì </p>
         *
         * @param strIn ÐèÒª×ª»»µÄ×Ö·û´®
         * @return ×ª»»ºóµÄbyteÊý×é
         * @throws Exception ±¾·½·¨²»´¦ÀíÈÎºÎÒì³££¬ËùÓÐÒì³£È«²¿Å×³ö
         * @author LiGuoQing
         */
        public byte[] hexStr2ByteArr(String strIn) throws Exception {
            byte[] arrB = strIn.getBytes();
            int iLen = arrB.length;
            byte[] arrOut = new byte[iLen / 2];
            for (int i = 0; i < iLen; i = i + 2) {
                String strTmp = new String(arrB, i, 2);
                arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16);
            }
            return arrOut;
        }

        /**
         * <p> Ö¸¶¨ÃÜÔ¿¹¹Ôì·½·¨</p>
         *
         * @param strKey Ö¸¶¨µÄÃÜÔ¿
         * @throws Exception
         */
        public DESPlus(String strKey) throws Exception {
            Security.addProvider(new com.sun.crypto.provider.SunJCE());
            Key key = getKey(strKey.getBytes());
            encryptCipher = Cipher.getInstance("DES");
            encryptCipher.init(Cipher.ENCRYPT_MODE, key);
            decryptCipher = Cipher.getInstance("DES");
            decryptCipher.init(Cipher.DECRYPT_MODE, key);
        }

        /**
         * <p> ¼ÓÃÜ×Ö½ÚÊý×é</p>
         *
         * @param arrB Ðè¼ÓÃÜµÄ×Ö½ÚÊý×é
         * @return ¼ÓÃÜºóµÄ×Ö½ÚÊý×é
         * @throws Exception
         */
        public byte[] encrypt(byte[] arrB) throws Exception {
            return encryptCipher.doFinal(arrB);
        }

        /**
         * <p> ¼ÓÃÜ×Ö·û´®</p>
         *
         * @param strIn Ðè¼ÓÃÜµÄ×Ö·û´®
         * @return ¼ÓÃÜºóµÄ×Ö·û´®
         * @throws Exception
         */
        public String encrypt(String strIn) throws Exception {
            return byteArr2HexStr(encrypt(strIn.getBytes()));
        }

        /**
         * <p> ¼ÓÃÜ×Ö·û´®</p>
         *
         * @param strIn Ðè¼ÓÃÜµÄ×Ö·û´®
         * @return ¼ÓÃÜºóµÄ×Ö·û´®
         * @throws Exception
         */
        public String encryptUTF(String strIn) throws Exception {
            return byteArr2HexStr(encrypt(strIn.getBytes("UTF-8")));
        }

        /**
         * <p> ½âÃÜ×Ö½ÚÊý×é	</p>
         *
         * @param arrB Ðè½âÃÜµÄ×Ö½ÚÊý×é
         * @return ½âÃÜºóµÄ×Ö½ÚÊý×é
         * @throws Exception
         */
        public byte[] decrypt(byte[] arrB) throws Exception {
            return decryptCipher.doFinal(arrB);
        }

        /**
         * <p> ½âÃÜ×Ö·û´® </p>
         *
         * @param strIn Ðè½âÃÜµÄ×Ö·û´®
         * @return ½âÃÜºóµÄ×Ö·û´®
         * @throws Exception
         */
        public String decrypt(String strIn) throws Exception {
            return new String(decrypt(hexStr2ByteArr(strIn)));
        }

        /**
         * <p>  ½âÃÜ×Ö·û´® </p>
         *
         * @param strIn Ðè½âÃÜµÄ×Ö·û´®
         * @return ½âÃÜºóµÄ×Ö·û´®
         * @throws Exception
         */
        public String decryptUTF(String strIn) throws Exception {
            return new String(decrypt(hexStr2ByteArr(strIn)), "UTF-8");
        }

        /**
         * <p> ´ÓÖ¸¶¨×Ö·û´®Éú³ÉÃÜÔ¿£¬ÃÜÔ¿ËùÐèµÄ×Ö½ÚÊý×é³¤¶ÈÎª8Î» ²»×ã8Î»Ê±ºóÃæ²¹0£¬³¬³ö8Î»Ö»È¡Ç°8Î» </p>
         *
         * @param arrBTmp ¹¹³É¸Ã×Ö·û´®µÄ×Ö½ÚÊý×é
         * @return Éú³ÉµÄÃÜÔ¿
         * @throws java.lang.Exception
         */
        private Key getKey(byte[] arrBTmp) throws Exception {
            byte[] arrB = new byte[8];
            for (int i = 0; i < arrBTmp.length && i < arrB.length; i++)
                arrB[i] = arrBTmp[i];
            Key key = new javax.crypto.spec.SecretKeySpec(arrB, "DES");
            return key;
        }
    }

    public static String getKeyedDigestUTF8(String strSrc, String key) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(strSrc.getBytes("UTF8"));
            String result = "";
            byte[] temp;
            temp = md5.digest(key.getBytes("UTF8"));
            for (int i = 0; i < temp.length; i++)
                result += Integer.toHexString((0x000000ff & temp[i]) | 0xffffff00).substring(6);
            return result;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


    private static String byteArray2HexString(byte arr[]) {
        StringBuilder sbd = new StringBuilder();
        for (byte b : arr) {
            String tmp = Integer.toHexString(0xff & b);
            if (tmp.length() < 2)
                tmp = (new StringBuilder()).append("0").append(tmp).toString();
            sbd.append(tmp);
        }
        return sbd.toString();
    }

    private static final int MAX_DECRYPT_BLOCK = 128;

    private static final int MAX_ENCRYPT_BLOCK = 117;

    private String encrypt(String content, String peerPublicKey) throws Exception {
        peerPublicKey = peerPublicKey.replaceAll("\\s*|\t|\r|\n", "");
        byte[] keyBytes = java.util.Base64.getDecoder().decode(peerPublicKey.getBytes());
        X509EncodedKeySpec bobPubKeySpec = new X509EncodedKeySpec(keyBytes);
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        PublicKey key = keyFactory.generatePublic(bobPubKeySpec);

        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.ENCRYPT_MODE, key);
        int inputLen = content.getBytes().length;
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        int offset = 0;
        byte[] cache;
        int i = 0;
        // 对数据分段加密
        while (inputLen - offset > 0) {
            if (inputLen - offset > MAX_ENCRYPT_BLOCK) {
                cache = cipher.doFinal(content.getBytes(), offset, MAX_ENCRYPT_BLOCK);
            } else {
                cache = cipher.doFinal(content.getBytes(), offset, inputLen - offset);
            }
            out.write(cache, 0, cache.length);
            i++;
            offset = i * MAX_ENCRYPT_BLOCK;
        }
        byte[] encryptedData = out.toByteArray();
        out.close();
        // 获取加密内容使用base64进行编码,并以UTF-8为标准转化成字符串
        // 加密后的字符串
        String encData = new String(java.util.Base64.getEncoder().encode(encryptedData));
        System.out.println(content + "," + encData);
        return encData;
    }

    private String sign(Map<String, Object> map, String privateKey) throws Exception {

        StringBuffer sb = new StringBuffer();
        ArrayList<String> mapKeys = new ArrayList<String>(map.keySet());
        Collections.sort(mapKeys);
        for (String key : mapKeys) {
            Object value = map.get(key);
            if (value == null || com.alibaba.druid.util.StringUtils.isEmpty(value.toString())) {
                continue;
            }
            sb.append(value);
        }
        String signStr = sb.toString();
        log.error("sign url " + signStr);
        privateKey = privateKey.replaceAll("\\s*|\t|\r|\n", "");
        byte[] keyBytes = java.util.Base64.getDecoder().decode(privateKey.getBytes("UTF-8"));
        PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        PrivateKey signKey = keyFactory.generatePrivate(spec);
        Signature signature = Signature.getInstance("SHA1withRSA");
        signature.initSign(signKey);
        signature.update(signStr.getBytes());

        String sign = byteArray2HexString(signature.sign()).toUpperCase();
        return sign;
    }

    public PayUrl facaizfUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return XGUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl tudouUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return theUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl qianchengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());

        String s = convertUrl(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("pay_md5sign", sign);
        sortedMap.put("pay_productname", "test");
        sortedMap.put("method", "post");

        String url = channel.getCreateUrl() + "?" + convertUrl(sortedMap, "&", "=");
        log.info("url {}", url);

        log.info("luoyao success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl shayuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("appid", platMer.getMerKey());
        map.put("appkey", platMer.getPublicKey());
        map.put("orderno", platMerOrderParam.getOrderId());
        map.put("amount", platMerOrderParam.getAmount().multiply(new BigDecimal(100)).intValue() + "");
        map.put("paytype", platMerBaseCode.getBaseCode());
        map.put("timestamp", System.currentTimeMillis());
        map.put("callbackurl", channel.getNotifyUrl());

        String s = convertUrlIsEmptyObject(map, "&", "=") + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("shayuUrl s " + s);
        log.info("shayuUrl sign " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("shayuUrl map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("shayuUrl body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("1".equals(jsonObject.getString("status"))) {
            log.info("shayuUrl success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("cashurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("shayuUrl return null");
        return null;
    }

    public PayUrl jzfUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("pay_memberid", platMer.getMerKey());
        map.put("pay_orderid", platMerOrderParam.getOrderId());
        map.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        map.put("pay_bankcode", platMerBaseCode.getBaseCode());
        map.put("pay_notifyurl", channel.getNotifyUrl());
        map.put("pay_callbackurl", channel.getNotifyUrl());
        map.put("pay_amount", (platMerOrderParam.getAmount()));

        String s = convertUrlIsEmptyObject(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinzhifuUrl launch s " + s);
        log.info("jinzhifuUrl launch md5(s) " + sign);

        map.put("pay_productname", "test");
        map.put("pay_md5sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinzhifuUrl launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinzhifuUrl body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("ok".equals(jsonObject.getString("status"))) {
            log.info("jinzhifuUrl success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinzhifuUrl return null");
        return null;
    }

    public PayUrl zhfUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return shejiaoUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl mianqianUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return dxerUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl kuaijieUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("server_no", "100008");
        map.put("trans_time", new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
        map.put("account", platMer.getMerKey());
        map.put("amount", platMerOrderParam.getAmount().multiply(new BigDecimal(100)).intValue());
        map.put("pay_mode", platMerBaseCode.getBaseCode());
        map.put("pay_source", "Web");

        StringBuffer buf = new StringBuffer();
        buf.append("{" + map.get("server_no") + "}|{");
        buf.append(map.get("trans_time") + "}|{");
        buf.append(map.get("account") + "}|{");
        buf.append(map.get("amount") + "}|{");
        buf.append(map.get("pay_mode") + "}|{");
        buf.append(platMer.getPrivateKey() + "}");


        //get sign
        String sign = (this.getKeyedDigest(buf.toString())).substring(0, 16).toUpperCase();
        System.out.println("Sign: " + buf.toString() + "   " + sign);

        map.put("aging", "1");
        map.put("app_id", platMerOrderParam.getOrderId());
        map.put("callback_url", channel.getNotifyUrl());
        map.put("notify_url", channel.getNotifyUrl());
        map.put("terminal_ip", "127.0.0.1");

        map.put("memo", "china");
        log.info("m {}", map);

        String context = this.getSignParam(map); // map to urldata &

        BASE64Encoder mBase64 = new BASE64Encoder();
        context = mBase64.encodeBuffer(context.getBytes()).trim();
        context = this.PackUrlBase64(context); //urlsafe
        context = context.replaceAll("(\\\r\\\n|\\\r|\\\n|\\\n\\\r)", "");//dele \n\r word;
        log.info("con {}", context);

        //create post data
        map.clear();
        map.put("syscode", "20000054");
        map.put("version", "002");
        map.put("context", context);
        map.put("signature", sign);

        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinzhifuUrl launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinzhifuUrl body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("0000".equals(jsonObject.getString("errorcode"))) {
            log.info("jinzhifuUrl success");
            String strSign = jsonObject.getString("signature");
            String unDecodeStr = this.UnPackUrlBase64(jsonObject.getString("context"));
            BASE64Decoder unBase64 = new BASE64Decoder(); //unBase64
            byte[] unByte = null;
            try {
                unByte = unBase64.decodeBuffer(jsonObject.getString("context"));
            } catch (IOException e) {
                e.printStackTrace();
            }

            unDecodeStr = null;
            try {
                unDecodeStr = new String(unByte, "GBK");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }


            //	    System.out.println(unDecodeStr);
            Map<String, String> url2Map = this.url2Map(unDecodeStr); //json data to map

            buf.setLength(0);
            buf.append("{" + url2Map.get("trans_id") + "}|{");
            buf.append(url2Map.get("amount") + "}|{");
            buf.append(url2Map.get("pay_url") + "}|{");
            buf.append(platMer.getPrivateKey() + "}");
            //sign
            String Retsign = (this.getKeyedDigest(buf.toString())).substring(0, 16).toUpperCase();
            System.out.println("Sign: " + buf.toString() + "   " + Retsign);

            if (!strSign.equals(Retsign)) {

                System.out.println("Sign Err " + Retsign + " return: " + strSign);
                return null;
            }

            //unpackbase64
            unDecodeStr = this.UnPackUrlBase64(url2Map.get("pay_url"));

            unByte = null;
            try {
                unByte = unBase64.decodeBuffer(unDecodeStr);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            unDecodeStr = null;
            try {
                unDecodeStr = new String(unByte, "GBK");
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            log.info("payUrl {}", unDecodeStr);
            return new PayUrl(1, channel.getChannelCode(), unDecodeStr, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinzhifuUrl return null");
        return null;
    }

    public static Map<String, String> url2Map(String urlparam) {
        Map<String, String> map = new HashMap<String, String>();
        String[] param = urlparam.split("&");
        for (String keyvalue : param) {
            String[] pair = keyvalue.split("=");
            if (pair.length == 2) {
                map.put(pair[0], pair[1]);
            }
        }
        return map;
    }

    public static String UnPackUrlBase64(String data) {

        data = data.replace("-", "+");
        data = data.replace("_", "/");

        while (data.length() % 4 != 0) {
            data += "=";
        }
        return data;

    }

    public static String PackUrlBase64(String data) {
        data = data.replace("+", "-");
        data = data.replace("/", "_");
        data = data.replace("=", "");
        return data;
    }

    public static String getSignParam(Map<String, Object> params) {
        StringBuilder buf = new StringBuilder((params.size() + 1) * 10);
        buildPayParams(buf, params, true);
        String result = buf.toString();
        return result;
    }

    /**
     * @param payParams
     * @return
     * @author
     */
    public static void buildPayParams(StringBuilder sb, Map<String, Object> payParams, boolean encoding) {
        List<String> keys = new ArrayList<String>(payParams.keySet());
        //Collections.sort(keys);
        for (String key : keys) {
            sb.append(key).append("=");
            if (encoding) {
                sb.append(urlEncode(payParams.get(key).toString()));
            } else {
                sb.append(payParams.get(key));
            }
            sb.append("&");
        }
        sb.setLength(sb.length() - 1);
    }

    public static String urlEncode(String str) {
        try {
            return URLEncoder.encode(str, "GBK");
        } catch (Throwable e) {
            return str;
        }
    }

    public static String getKeyedDigest(String strSrc) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(strSrc.getBytes("GBK"));

            String result = "";
            byte[] temp;
            temp = md5.digest();
            for (int i = 0; i < temp.length; i++) {
                result += Integer.toHexString((0x000000ff & temp[i]) | 0xffffff00).substring(6);
            }

            return result;

        } catch (NoSuchAlgorithmException e) {

            e.printStackTrace();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public PayUrl ronghuixinUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("uid", platMer.getMerKey());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("money", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("channel", platMerBaseCode.getBaseCode());
        map.put("outTradeNo", platMerOrderParam.getOrderId());
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("returnUrl", channel.getNotifyUrl());
        map.put("timestamp", Convert.toStr(System.currentTimeMillis()));
        map.put("goodsName", "test");
        map.put("outUserId", UUID.randomUUID().toString().replace("-", ""));
        map.put("token", platMer.getPrivateKey());

        String s = convertUrlIsEmptyObject(map, "&", "=");

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("ronghuixin launch s " + s);
        log.info("ronghuixin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("ronghuixin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("ronghuixin body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("0".equals(jsonObject.getString("code"))) {
            log.info("ronghuixin success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("ronghuixin return null");
        return null;
    }

    public PayUrl haoyunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("totalFee", platMerOrderParam.getAmount().multiply(new BigDecimal(100)));
        map.put("sdorderNo", platMerOrderParam.getOrderId());
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("payments", platMerBaseCode.getBaseCode());
        map.put("goodsId", "140");
        map.put("userId", platMer.getMerKey());

        String s = convertUrlIsEmptyObject(map, "&", "=") + "key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s);
        log.info("haoyunUrl launch s " + s);
        log.info("haoyunUrl launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("haoyunUrl launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("haoyunUrl body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("success".equals(jsonObject.getString("code"))) {
            log.info("haoyunUrl success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("haoyunUrl return null");
        return null;
    }

    public PayUrl moqingUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());

        String s = convertUrl(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("s {}  sign {}", s, sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("pay_md5sign", sign);
        sortedMap.put("pay_productname", "test");

        String url = channel.getCreateUrl() + "?" + convertUrl(sortedMap, "&", "=");
        log.info("url {}", url);

        log.info("moqingUrl success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl shangtianUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        String url = channel.getCreateUrl() + "?amount=" + platMerOrderParam.getAmount() + "&orderId=" + platMerOrderParam.getOrderId();
        String body = HttpUtil.createGet(url).execute().body();
        log.info("haoyunUrl body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("200".equals(jsonObject.getString("code"))) {
            log.info("haoyunUrl success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        return null;
    }

    public PayUrl yundingUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("mch_id", platMer.getMerKey());
        sortedMap.put("ptype", platMerBaseCode.getBaseCode());
        sortedMap.put("order_sn", platMerOrderParam.getOrderId());
        sortedMap.put("money", platMerOrderParam.getAmount().intValue());
        sortedMap.put("goods_desc", "good");
        sortedMap.put("client_ip", platMerOrderParam.getClientIp().split(",")[0].trim());
        sortedMap.put("format", "page");
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("time", (System.currentTimeMillis() / 1000) + "");


        String s = convertUrlIsEmptyObject(sortedMap, "&", "=");


        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&key=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toLowerCase();

        sortedMap.put("sign", sign);

        log.info("map {} ", sortedMap);

        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(sortedMap, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl shandianUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
//        OkHttpClient client = new OkHttpClient();
//
//        MediaType mediaType = MediaType.parse("application/json");
//        RequestBody body = RequestBody.create(mediaType, "{\n\t\"orderNo\": \"33333333\",\n\t\"channel\": \"PJT_WEIXIN\",\n\t\"amount\": 1000,\n\t\"subject\": \"京东\"\n}");
//        Request request = new Request.Builder()
//                .url("http://api.pay.gwcanada.com/charges/")
//                .post(body)
//                .addHeader("authorization", "Basic NGNhZmVhMzM3YWIyNDJkZGE1NzNiYTIzMDAxOTc0MWI6")
//                .addHeader("content-type", "application/json")
//                .build();
//
//        Response response = client.newCall(request).execute();

        Map<String, Object> sortedMap = new TreeMap<>();

        sortedMap.put("orderNo", platMerOrderParam.getOrderId());
        sortedMap.put("channel", platMerBaseCode.getBaseCode());
        sortedMap.put("amount", platMerOrderParam.getAmount().multiply(new BigDecimal(100)));
        sortedMap.put("subject", "test");
        log.info("map {}", sortedMap);

        Map<String, String> headerMap = new HashMap<>();
        headerMap.put("authorization", "Basic NGNhZmVhMzM3YWIyNDJkZGE1NzNiYTIzMDAxOTc0MWI6");
        headerMap.put("content-type", "application/json");
        String body = HttpUtil.createPost("http://api.pay.gwcanada.com/charges/").body(JSON.toJSONString(sortedMap)).headerMap(headerMap, true).execute().body();
        log.info("body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);

        return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("extra"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl kxUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return kuaixunUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl kx2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return kubeiUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl yuechuangUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, String> map = new TreeMap<>();
        map.put("cmd", platMerBaseCode.getBaseCode());
        map.put("version", "2.0");
        map.put("appid", platMer.getMerKey());
        map.put("ordertime", DateUtil.format(new Date(), "yyyyMMddHHmmss"));
        map.put("userid", platMer.getWithdrawKey());
        map.put("apporderid", platMerOrderParam.getOrderId());
        map.put("orderbody", "222.65.183.51");
        map.put("orderdesc", "test");
        map.put("amount", platMerOrderParam.getAmount().toString());
        map.put("notifyurl", channel.getNotifyUrl());
        map.put("front_skip_url", channel.getNotifyUrl());

        String s = convertUrl(map, "&", "=");
        log.info("s {}", s);

        log.info("privateKey {}", platMer.getPrivateKey());

        String hmac = getKeyedDigestUTF8(s, platMer.getPrivateKey());
        log.info("hmac {}", hmac);

        map.put("hmac", hmac);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("yuechuang map " + map);

//        String createParam = this.createParam(map, platMer.getPrivateKey());
//        Map<String, List<String>> decodeParams = HttpUtil.decodeParams(createParam, "UTF-8");
//        StringBuffer from = this.getFrom(decodeParams, channel.getNotifyUrl());
//        log.info("form {}", from);

        String url = channel.getCreateUrl() + "?" + convertUrl(map, "&", "=");
        log.info("url {}", url);

        log.info("moqingUrl success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public static String createParam(Map<String, String> map, String appInitKey) {
        try {
            if (map == null || map.isEmpty())
                return null;
            Object[] key = map.keySet().toArray();
            Arrays.sort(key);
            StringBuffer res = new StringBuffer(128);
            for (int i = 0; i < key.length; i++)
                res.append(key[i]).append("=").append(map.get(key[i])).append("&");
            String rStr = res.substring(0, res.length() - 1);
            if (appInitKey == null)
                return rStr + "&hmac=" + getKeyedDigestUTF8(rStr, appInitKey);
            System.out.println("&hmac=" + getKeyedDigestUTF8(rStr, appInitKey));
            return rStr + "&hmac=" + getKeyedDigestUTF8(rStr, appInitKey);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }

    public static StringBuffer getFrom(Map<String, List<String>> decodeParams, String url) {
        Set<String> keySet = decodeParams.keySet();
        StringBuffer buffer = new StringBuffer();
        buffer.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">")
                .append("<html>")
                .append("<head>")
                .append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">")
                .append("</head>")
                .append("<body>")
                .append("<form action=\"" + url + "\" id=\"from\" method=\"post\" >");
        for (String key : keySet) {
            List<String> list = decodeParams.get(key);
            String first = CollUtil.getFirst(list);
            buffer.append("<input type=\"hidden\" name=\"" + key + "\" value=\"" + first + "\">");
        }
        buffer
                .append("</form>")
                .append("</body>")
                .append("</html>")
                .append("<script language=javascript>")
                .append("window.onload= function(){\r\n" +
                        "document.getElementById('from').submit();\r\n" +
                        "}")
                .append("</script>");
        return buffer;
    }

    public PayUrl guangxinUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("mchNo", platMer.getMerKey());
        sortedMap.put("mchUserNo", platMer.getMerKey());
        sortedMap.put("outTradeNo", platMerOrderParam.getOrderId());
        sortedMap.put("channel", platMerBaseCode.getBaseCode());
        sortedMap.put("amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        sortedMap.put("body", "Test");
        sortedMap.put("payDate", DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN));
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("returnUrl", channel.getNotifyUrl());

        String s = convertUrl(sortedMap, "&", "=") + "&signKey=" + platMer.getPrivateKey();
        log.info("guangxin s {}", s);

        String sign = SecureUtil.md5(s);
        log.info("guangxin sign {}", sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);
        log.info("guangxin map {}", sortedMap);

        String url = channel.getCreateUrl() + "?" + convertUrl(sortedMap, "&", "=");
        log.info("guangxin {}", url);

        log.info("guangxin success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl kUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("appKey", platMer.getMerKey());
        map.put("outOrderId", platMerOrderParam.getOrderId());
        map.put("payAmount", platMerOrderParam.getAmount());
        map.put("payType", platMerBaseCode.getBaseCode());
        map.put("payeeName", "test");
        map.put("noncestr", getRandom(12));
        map.put("receiveUrl", channel.getNotifyUrl());
        map.put("signType", "MD5");
        map.put("lootReceiveUrl", channel.getNotifyUrl());
        map.put("timestamp", System.currentTimeMillis());

        String s = map.get("payeeName").toString() + map.get("outOrderId") + map.get("payAmount") + map.get("receiveUrl") + map.get("noncestr")
                + map.get("timestamp") + map.get("signType") + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s);
        log.info("ronghuixin launch s " + s);
        log.info("ronghuixin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("ronghuixin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("ronghuixin body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("1".equals(jsonObject.getString("code"))) {
            log.info("ronghuixin success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payPageUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("ronghuixin return null");
        return null;
    }

    public static String getRandom(int length) {
        String val = "";
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            val += String.valueOf(random.nextInt(10));
        }
        return val;
    }

    public PayUrl wanxiangUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("merCode", platMer.getMerKey());
        map.put("orderNo", platMerOrderParam.getOrderId());
        map.put("amount", new BigDecimal(100).multiply(platMerOrderParam.getAmount()));
        map.put("payCode", platMerBaseCode.getBaseCode());
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("backUrl", channel.getNotifyUrl());
        map.put("orderTime", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
        map.put("userOrderIP", "127.0.0.1");

        String s = convertUrlIsEmptyObject(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("ronghuixin launch s " + s);
        log.info("ronghuixin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("ronghuixin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("ronghuixin body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("1".equals(jsonObject.getString("code"))) {
            log.info("ronghuixin success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("ronghuixin return null");
        return null;
    }

    public PayUrl yuntengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();


        map.put("merCode", platMer.getMerKey());
        map.put("orderNo", platMerOrderParam.getOrderId());
        map.put("amount", new BigDecimal(100).multiply(platMerOrderParam.getAmount()));
        map.put("payCode", platMerBaseCode.getBaseCode());
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("backUrl", channel.getNotifyUrl());
        map.put("orderTime", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
        map.put("userOrderIP", "127.0.0.1");

        String s = convertUrlIsEmptyObject(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("ronghuixin launch s " + s);
        log.info("ronghuixin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("ronghuixin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("ronghuixin body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("1".equals(jsonObject.getString("code"))) {
            log.info("ronghuixin success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("ronghuixin return null");
        return null;
    }

    public PayUrl antengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("version", "3.0");
        map.put("method", "Gt.online.interface");
        map.put("partner", platMer.getMerKey());
        map.put("banktype", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("paymoney", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("ordernumber", platMerOrderParam.getOrderId());
        map.put("callbackurl", channel.getNotifyUrl());

        String s = convertUrlIsEmptyObject(map, "&", "=") + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toLowerCase();
        map.put("sign", sign);
        map.put("notreturnpage", true);
        log.info("hongYi s " + s);
        log.info("hongYi sign " + sign);

        map.put("hrefbackurl", channel.getNotifyUrl());
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("hongYi map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("1000".equals(jsonObject.getString("code"))) {
            log.info("hongYi success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hongYi return null");
        return null;
    }


    public PayUrl yeziUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return moqingUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl changfutongUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", new DecimalFormat("0").format(platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("clientIp", "127.0.0.1");
        map.put("device", "WEB");                              // 设备
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("extra", "{\"cardCode\":\"MOBILE\",\"cardAmt\": \"10\",\"cardNo\": \"17329198803183425\",\"cardPwd\": \"353687724098502509\"}");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("changfutong launch s " + s);
        log.info("changfutong launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("changfutong launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("changfutong launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("changfutong launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("codeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("changfutong launch return null");
        return null;
    }

    public PayUrl longfaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return moqingUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    /**
     * 加密字节数据
     *
     * @param content
     * @param key
     * @return
     */
    private static final String CipherMode = "AES/ECB/PKCS5Padding";

    public static String byte2hex(byte[] b) { // 一个字节的数，
        StringBuffer sb = new StringBuffer(b.length * 2);
        String tmp;
        for (int n = 0; n < b.length; n++) {
            // 整数转成十六进制表示
            tmp = (Integer.toHexString(b[n] & 0XFF));
            if (tmp.length() == 1) {
                sb.append("0");
            }
            sb.append(tmp);
        }
        return sb.toString().toUpperCase(); // 转成大写
    }

    /**
     * 将hex字符串转换成字节数组
     *
     * @param inputString
     * @return
     */
    private static byte[] hex2byte(String inputString) {
        if (inputString == null || inputString.length() < 2) {
            return new byte[0];
        }
        inputString = inputString.toLowerCase();
        int l = inputString.length() / 2;
        byte[] result = new byte[l];
        for (int i = 0; i < l; ++i) {
            String tmp = inputString.substring(2 * i, 2 * i + 2);
            result[i] = (byte) (Integer.parseInt(tmp, 16) & 0xFF);
        }
        return result;
    }

    public static byte[] encrypt2(byte[] content, byte[] key) throws Exception {
        Cipher cipher = Cipher.getInstance(CipherMode);
        cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"));
        byte[] result = cipher.doFinal(content);
        return result;
    }

    public static String encrypt1(String content, String key) throws Exception {
        byte[] data = null;
        try {
            data = content.getBytes("UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
        }
        data = encrypt2(data, new SecretKeySpec(hex2byte(key), "AES").getEncoded());
        String result = byte2hex(data);
        return result;
    }

    public PayUrl zongcaiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws Exception {
        Map<String, Object> map = new TreeMap();
        map.put("input_charset", "utf-8");
        map.put("inform_url", channel.getNotifyUrl());
        map.put("return_url", channel.getNotifyUrl());
        map.put("pay_type", platMerBaseCode.getBaseCode());
//        map.put("bank_code", platMerBaseCode.getBaseCode());
        map.put("merchant_code", platMer.getMerKey());
        map.put("order_no", platMerOrderParam.getOrderId());
        map.put("order_amount", this.encrypt1(platMerOrderParam.getAmount().toString(), platMer.getPrivateKey()));
        map.put("order_time", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
        map.put("customer_ip", "127.0.0.1");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);
        log.info("zongcai launch s " + s);
        log.info("zongcai launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("zongcai launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("zongcai launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("true").equals(jsonObject.getString("is_success"))) {
            log.info("zongcai launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("bus_content"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("zongcai launch return null");
        return null;
    }


    public PayUrl jinyuanUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("callbackurl", channel.getNotifyUrl());
        sortedMap.put("orderid", platMerOrderParam.getOrderId());
        sortedMap.put("merchant", platMer.getMerKey());
        sortedMap.put("type", platMerBaseCode.getBaseCode());
        sortedMap.put("value", platMerOrderParam.getAmount().toString());

        String s = convertUrl(sortedMap, "&", "=") + platMer.getPrivateKey();
        log.info("jinyuan s {}", s);

        String sign = SecureUtil.md5(s).toLowerCase();
        log.info("jinyuan sign {}", sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);
        log.info("jinyuan map {}", sortedMap);

        String url = channel.getCreateUrl() + "?" + convertUrl(sortedMap, "&", "=");
        log.info("jinyuan {}", url);

        log.info("jinyuan success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }


    public PayUrl shuiguoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("appid", platMer.getMerKey());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("callback_url", channel.getNotifyUrl());
        map.put("success_url", channel.getNotifyUrl());
        map.put("error_url", channel.getNotifyUrl());
        map.put("out_uid", "15017399440");
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("version", "v3.0");
        log.info(" shuiguo map " + map);

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("shuiguo launch s " + s);
        log.info("shuiguo launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("shuiguo launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("shuiguo launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("shuiguo launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("qrcode"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("shuiguo launch return null");
        return null;

    }

    public PayUrl qianyifuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("pay_memberid", platMer.getMerKey());
        map.put("pay_orderid", platMerOrderParam.getOrderId());
        map.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        map.put("pay_bankcode", platMerBaseCode.getBaseCode());
        map.put("pay_notifyurl", channel.getNotifyUrl());
        map.put("pay_callbackurl", channel.getNotifyUrl());
        map.put("pay_amount", (platMerOrderParam.getAmount()));

        String s = convertUrlIsEmptyObject(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinzhifuUrl launch s " + s);
        log.info("jinzhifuUrl launch md5(s) " + sign);

        map.put("pay_md5sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinzhifuUrl launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinzhifuUrl body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("1".equals(jsonObject.getString("state"))) {
            log.info("jinzhifuUrl success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinzhifuUrl return null");
        return null;
    }

    public PayUrl yingfutongUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("user_id", platMer.getMerKey());
        map.put("order_id", platMerOrderParam.getOrderId());
        map.put("return_url", channel.getNotifyUrl());
        map.put("notice_url", channel.getNotifyUrl());
        map.put("amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        map.put("paytype", platMerBaseCode.getBaseCode());
        map.put("remarks", "test");

        String s = convertUrlIsEmptyObject(map, "&", "=") + "&token=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("yingfutong launch s " + s);
        log.info("yingfutong launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("yingfutong launch map " + map);

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "=");
        log.info("yingfutong {}", url);

        log.info("yingfutong success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl bangshengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam
            platMerOrderParam, MerChannel channel) {
        return luoyaoUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl cftUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("clientIp", "34.80.174.100");
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("extra", "{ \"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("codeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }

    public PayUrl xiaodizhuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return qianjinfuUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl xiaofeiyuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return fcpayUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl jueqiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam
            platMerOrderParam, MerChannel channel) {
        return luoyaoUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl shuangshengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("merchantNum", platMer.getMerKey());
        sortedMap.put("orderNo", platMerOrderParam.getOrderId());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("payType", platMerBaseCode.getBaseCode());

        String signUrl = platMer.getMerKey() + platMerOrderParam.getOrderId() + decimalFormat.format(platMerOrderParam.getAmount()) + channel.getNotifyUrl() + platMer.getPrivateKey();
        log.info("s {}", signUrl);
        sortedMap.put("sign", SecureUtil.md5(signUrl).toLowerCase());

        sortedMap.put("returnUrl", channel.getNotifyUrl());
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("yi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("yi launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("yi launch error");
        return null;
    }


    public PayUrl hcUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return shuangshengUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl yunding2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return tbdfh5Url(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl ziyouUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("tradeNo", platMerOrderParam.getOrderId());
        sortedMap.put("payType", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("orderPrice", decimalFormat.format(platMerOrderParam.getAmount()));
        sortedMap.put("merchantId", platMer.getMerKey());
        sortedMap.put("productName", "test");
        sortedMap.put("remark", "test");
        sortedMap.put("notifyUrl", channel.getNotifyUrl());

        String s = convertUrlNotEmpty(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        log.info("s {}", s);
        sortedMap.put("sign", SecureUtil.md5(s).toUpperCase());

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("yi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("yi launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("obj").getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("yi launch error");
        return null;
    }

    public PayUrl lxUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return shuangshengUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl kaer2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("merchantNum", platMer.getMerKey());
        sortedMap.put("orderNo", platMerOrderParam.getOrderId());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("payType", platMerBaseCode.getBaseCode());

        String signUrl = platMer.getMerKey() + "&" + platMerOrderParam.getOrderId() + "&" +
                decimalFormat.format(platMerOrderParam.getAmount()) + "&" + channel.getNotifyUrl() + "&" + platMer.getPrivateKey();
        log.info("s {}", signUrl);
        sortedMap.put("sign", SecureUtil.md5(signUrl).toLowerCase());

        sortedMap.put("returnUrl", "http://www.baidu.com");
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("yi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("yi launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("yi launch error");
        return null;
    }

    public PayUrl aUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("version", "3.0");
        map.put("method", "Gt.online.interface");
        map.put("partner", platMer.getMerKey());
        map.put("banktype", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("paymoney", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("ordernumber", platMerOrderParam.getOrderId());
        map.put("callbackurl", channel.getNotifyUrl());

        String s = convertUrlIsEmptyObject(map, "&", "=") + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toLowerCase();
        map.put("sign", sign);
        map.put("notreturnpage", true);
        log.info("hongYi s " + s);
        log.info("hongYi sign " + sign);
        map.put("hrefbackurl", channel.getNotifyUrl());
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("hongYi map " + map);
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getInteger("code").intValue() == 1000) {
            log.info("hongYi success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hongYi return null");
        return null;
    }

    public PayUrl daitouUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("uid", platMer.getMerKey());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("price", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("istype", platMerBaseCode.getBaseCode());
        map.put("notify_url", channel.getNotifyUrl());
        map.put("return_url", channel.getNotifyUrl());
        map.put("orderid", platMerOrderParam.getOrderId());
        map.put("token", platMer.getPrivateKey());
        map.put("orderuid", "test");
        map.put("goodsname", "test");

        StringBuilder stringBuilder = new StringBuilder();
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            stringBuilder.append(entry.getValue());
        }

        String s = stringBuilder.toString();

        String sign = SecureUtil.md5(s).toLowerCase();
        map.put("key", sign);

        map.remove("token");

        log.info("hongYi s " + s);
        log.info("hongYi sign " + sign);

        log.info("hongYi map " + map);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getInteger("code").intValue() == 1) {
            log.info("hongYi success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hongYi return null");
        return null;
    }

    public PayUrl ysUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return yundingUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl huoxingUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return yundingUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl openUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return yundingUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl kkUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return yundingUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl nanjiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws DigestException, UnsupportedEncodingException, NoSuchAlgorithmException {
        Map<String, Object> map = new TreeMap<>();
        map.put("amount", platMerOrderParam.getAmount());
        map.put("address", "test");
        map.put("username", "test");
        map.put("orderid", platMerOrderParam.getOrderId());
        map.put("appid", platMer.getMerKey());
        map.put("return_url", channel.getNotifyUrl());
        map.put("notify_url", channel.getNotifyUrl());
        String decrypt = getOrderByLexicographic(map) + platMer.getPrivateKey();

//
        log.error("decrypt {}", decrypt);
        MessageDigest md = MessageDigest.getInstance("SHA-1");


        md.update(decrypt.getBytes());


        byte[] digest = md.digest();


        StringBuffer sb = new StringBuffer();


        for (byte b : digest) {


            sb.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));


        }

        log.error("content {}", sb.toString().toUpperCase());
        log.error("content {}", sb.toString());
//        String s = convertUrlIsEmptyObject(map, "", "")+ platMer.getPrivateKey();
//        String sign = SecureUtil.sha1(s).toUpperCase();
        map.put("sign", sb.toString().toUpperCase());
//        map.put("channel", platMer.getChannelCode());

//        log.info("hongYi s " + s);
        log.info("hongYi sign " + sb.toString().toUpperCase());
        log.info("hongYi map " + map);
        map.put("channel", platMerBaseCode.getBaseCode());

        map.put(Epay.REAL_URL, channel.getRealUrl());

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getInteger("status").intValue() == 1) {
            log.info("hongYi success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hongYi return null");
        return null;
    }

    public static String encrypt(String content) {
        try {
            // Create MD5 Hash
            MessageDigest digest = MessageDigest.getInstance("SHA-1");
            digest.update(content.getBytes());
            byte messageDigest[] = digest.digest();

            // Create Hex String
            StringBuffer hexString = new StringBuffer();
            for (int i = 0; i < messageDigest.length; i++)
                hexString.append(String.format("%02X", 0xFF & messageDigest[i]));

            return hexString.toString().toLowerCase();

        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return "";
    }

    public String SHA1(Map<String, Object> maps) throws DigestException {
//获取信息摘要 - 参数字典排序后字符串  
        String decrypt = getOrderByLexicographic(maps);
        try {
//指定sha1算法  
            MessageDigest digest = MessageDigest.getInstance("SHA-1");
            digest.update(decrypt.getBytes());
//获取字节数组  
            byte messageDigest[] = digest.digest();
// Create Hex String  
            StringBuffer hexString = new StringBuffer();
// 字节数组转换为 十六进制 数  
            for (int i = 0; i < messageDigest.length; i++) {
                String shaHex = Integer.toHexString(messageDigest[i] & 0xFF);
                if (shaHex.length() < 2) {
                    hexString.append(0);
                }
                hexString.append(shaHex);
            }
            return hexString.toString().toUpperCase();

        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            throw new DigestException("签名错误！");
        }
    }

    private static String getOrderByLexicographic(Map<String, Object> maps) {
        return splitParams(lexicographicOrder(getParamsName(maps)), maps);
    }

    /**
     *      * 获取参数名称 key
     *      * @param maps 参数key-value map集合
     *      * @return
     *     
     */
    private static List<String> getParamsName(Map<String, Object> maps) {
        List<String> paramNames = new ArrayList<String>();
        for (Map.Entry<String, Object> entry : maps.entrySet()) {
            paramNames.add(entry.getKey());
        }
        return paramNames;
    }

    /**
     *      * 参数名称按字典排序
     *      * @param paramNames 参数名称List集合
     *      * @return 排序后的参数名称List集合
     *     
     */
    private static List<String> lexicographicOrder(List<String> paramNames) {
        Collections.sort(paramNames);
        return paramNames;
    }

    /**
     *      * 拼接排序好的参数名称和参数值
     *      * @param paramNames 排序后的参数名称集合
     *      * @param maps 参数key-value map集合
     *      * @return String 拼接后的字符串
     *     
     */
    private static String splitParams(List<String> paramNames, Map<String, Object> maps) {
        StringBuilder paramStr = new StringBuilder();
        for (String paramName : paramNames) {
            paramStr.append(paramName);
            for (Map.Entry<String, Object> entry : maps.entrySet()) {
                if (paramName.equals(entry.getKey())) {
                    paramStr.append(String.valueOf(entry.getValue()));
                }
            }
        }
        return paramStr.toString();
    }


    public PayUrl leishenUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("apiCode", "YL-PAY");
        map.put("inputCharset", "UTF-8");
        map.put("signType", "MD5");
        map.put("partner", platMer.getMerKey());
        map.put("outOrderId", platMerOrderParam.getOrderId());
        map.put("payType", "ddpay");
        map.put("interfaceCode", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("notifyUrl", channel.getNotifyUrl());

        String s = convertUrlIsEmptyObject(map, "&", "=") + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();

        map.put("sign", sign);
        log.info("hongYi s " + s);
        log.info("hongYi sign " + sign);
        log.info("hongYi map " + map);

        map.put(Epay.REAL_URL, channel.getRealUrl());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getInteger("responseCode").intValue() == 0000) {
            log.info("hongYi success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("qrCodeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hongYi return null");
        return null;
    }

    public PayUrl yinshangfuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("return_type", "html");
        map.put("api_code", platMer.getMerKey());
        map.put("is_type", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("price", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("order_id", platMerOrderParam.getOrderId());
        map.put("return_url", channel.getNotifyUrl());
        map.put("notify_url", channel.getNotifyUrl());
        map.put("time", System.currentTimeMillis() / 1000);
        map.put("mark", "test");

//        map.put("extra", "{\"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}\t");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl shunfuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws Exception {
        Map<String, Object> map = new TreeMap<>();
        map.put("merchantsNo", platMer.getMerKey());
        map.put("orderNo", platMerOrderParam.getOrderId());
        map.put("referTime", System.currentTimeMillis() / 1000);
        map.put("payCode", platMerBaseCode.getBaseCode());
        map.put("serverUrl", channel.getNotifyUrl());
        map.put("returnUrl", channel.getNotifyUrl());
        map.put("amount", platMerOrderParam.getAmount());

        //排序 并 拼装成json字符串
        //paramsString 为排序好的字符串
        String str = convertUrlNotEmpty(map, "&", "=");
        log.info("shunfu s {}", str);
        log.info("private {}", platMer.getPrivateKey());

        String sign = this.signByPrivateKey(str.getBytes("UTF-8"), platMer.getPrivateKey());

        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public static String signByPrivateKey(byte[] data, String privateKey) throws Exception {
        byte[] keyBytes = decryptBASE64(privateKey);
        PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
        KeyFactory factory = KeyFactory.getInstance("RSA");
        PrivateKey priKey = factory.generatePrivate(keySpec);// 生成私钥
        // 用私钥对信息进行数字签名
        Signature signature = Signature.getInstance("SHA256withRSA");
        signature.initSign(priKey);
        signature.update(data);
        return encryptBASE64(signature.sign());

    }

    private static String encryptBASE64(byte[] data) {
        return new String(Base64.encodeBase64(data));
    }

    private static byte[] decryptBASE64(String data) {
        return Base64.decodeBase64(data);
    }

    public PayUrl wandeUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return binliUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl beidouxingUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map sortedMap = new TreeMap();
        sortedMap.put("mch_id", platMer.getMerKey());
        sortedMap.put("out_trade_no", platMerOrderParam.getOrderId());
        sortedMap.put("amount", (new BigDecimal(100).multiply(platMerOrderParam.getAmount())).toString());
        sortedMap.put("callback_url", channel.getNotifyUrl());
        sortedMap.put("service_type", platMerBaseCode.getBaseCode());

        String s = convertUrl(sortedMap, "&", "=") + "&KEY=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();

        sortedMap.put("goods", "test");
        sortedMap.put("return_url", channel.getNotifyUrl());
        sortedMap.put("sign", sign);
        log.info("hongYi s " + s);
        log.info("hongYi sign " + sign);


        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("hongYi map " + sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getInteger("code").intValue() == 1) {
            log.info("hongYi success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("link_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hongYi return null");
        return null;
    }

    public PayUrl xiaowuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());

        String s = convertUrlIsEmptyObject(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();

        sortedMap.put("pay_md5sign", sign);
        log.info("hongYi s " + s);
        log.info("hongYi sign " + sign);
        log.info("hongYi map " + sortedMap);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getInteger("code").intValue() == 200) {
            log.info("hongYi success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hongYi return null");
        return null;
    }

    public PayUrl ziyou1Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam
            platMerOrderParam, MerChannel channel) {
        return luoyaoUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl ggUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("version", "1.0");
        map.put("custid", platMer.getMerKey());
        map.put("ordercode", platMerOrderParam.getOrderId());
        map.put("ordertype", platMerBaseCode.getBaseCode());
        map.put("amount", new BigDecimal(100).multiply(platMerOrderParam.getAmount()));
        map.put("backurl", channel.getNotifyUrl());
        map.put("backmemo", "test");

        String s = convertUrlIsEmptyObject(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);
        map.put("sign", sign);
        log.info("hongYi s " + s);
        log.info("hongYi sign " + sign);
        map.put("hrefbackurl", channel.getNotifyUrl());
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("hongYi map " + map);
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getString("code").equals("SUCCESS")) {
            log.info("hongYi success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("codeurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hongYi return null");
        return null;
    }


    public PayUrl lesumaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("MemberId", Integer.parseInt(platMer.getMerKey()));
        map.put("OrderId", platMerOrderParam.getOrderId());
        map.put("Date", DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"));
        map.put("PayType", platMerBaseCode.getBaseCode());
        map.put("NotifyUrl", channel.getNotifyUrl());
        map.put("CallbackUrl", channel.getNotifyUrl());
        map.put("Amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));

        String s = convertUrlIsEmptyObject(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        map.put("Sign", sign);
//        map.put("GoodsName", "test");
        map.put("ReturnType", 1);

        log.info("hongYi s " + s);
        log.info("hongYi sign " + sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("hongYi map " + map);
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getString("status").equals("success")) {
            log.info("hongYi success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hongYi return null");
        return null;
    }

    public PayUrl ruanyuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("tradeNo", platMerOrderParam.getOrderId());
        sortedMap.put("payType", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("orderPrice", decimalFormat.format(platMerOrderParam.getAmount()));
        sortedMap.put("merchantId", platMer.getMerKey());
        sortedMap.put("productName", "test");
        sortedMap.put("remark", "test");
        sortedMap.put("notifyUrl", channel.getNotifyUrl());

        String s = convertUrlNotEmpty(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        log.info("s {}", s);
        sortedMap.put("sign", SecureUtil.md5(s).toUpperCase());

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(sortedMap, "&", "=");
        log.info("yingfutong {}", url);

        log.info("yingfutong success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

    }

    public PayUrl baiyiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String, Object> business = new TreeMap<>();
        business.put("service", "service.ffff.pay");
        business.put("merchant_id", platMer.getMerKey());
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        business.put("request_time", simpleDateFormat.format(platMerOrderParam.getCreatedAt()));
        business.put("nonce_str", UUID.randomUUID().toString().replaceAll("-", ""));
        business.put("version", "V1.1");
//        business.put("sign_type", "MD5");

        Map<String, Object> data = new TreeMap<>();
        data.put("order_no", platMerOrderParam.getOrderId());
        DecimalFormat df = new DecimalFormat("0.00");
        data.put("amount", df.format(platMerOrderParam.getAmount()));
        data.put("notify_url", channel.getNotifyUrl());
        data.put("return_url", channel.getNotifyUrl());
        data.put("currency", "CNY");
        data.put("trade_code", platMerBaseCode.getBaseCode());
        data.put("client_ip", "127.0.0.1");
        data.put("terminal_type", "pc");

        Map<String, Object> sort = new TreeMap<>();
        sort.putAll(business);
        sort.putAll(data);
        log.info("sign map {}", sort);

        String s = convertUrlIsEmptyObject(sort, "&", "=") + "&key=" + platMer.getPrivateKey();

        log.error("jjzhifu url md5 {}", s);
        business.put("sign_type", "MD5");
        business.put("sign", SecureUtil.md5(s).toUpperCase());
        business.put("data", data);

        business.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("map {}", business);

        String body = HttpUtil.createPost(channel.getRealUrl()).body(JSONObject.toJSONString(business)).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);

        log.info("result a jjzhifu {}", body);
        if (jsonObject.getInteger("resp_code").intValue() == 1000) {
            log.info("success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_info"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }
        return null;

    }

    public PayUrl baobeiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))).intValue()+"");
        map.put("notifyUrl", channel.getNotifyUrl());

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }

    public PayUrl huitengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mch_id", platMer.getMerKey());
        map.put("timestamp", System.currentTimeMillis() / 1000);
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        map.put("total_fee", platMerOrderParam.getAmount());
        map.put("notify_url", channel.getNotifyUrl());
        map.put("mch_secret", platMer.getPrivateKey());

        String s = convertUrlNotEmpty(map, "&", "=");
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("100").equals(jsonObject.getString("code"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }

    public PayUrl guiguUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("merchantid", platMer.getMerKey());
        map.put("merchantorderid", platMerOrderParam.getOrderId());
        map.put("orderchannel", platMerBaseCode.getBaseCode());
        map.put("applyamount", platMerOrderParam.getAmount());
        map.put("callbackurl", channel.getNotifyUrl());
        map.put("timestamp", System.currentTimeMillis());

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("0").equals(jsonObject.getString("code"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }

    public PayUrl ifUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("userId", platMer.getMerKey());
        DecimalFormat df = new DecimalFormat("0.00");
        map.put("tradeAmt", df.format(platMerOrderParam.getAmount()));
        map.put("orderRemark", platMerOrderParam.getOrderId());
        map.put("nbNotifyUrl", channel.getNotifyUrl());
        map.put("key", platMer.getPrivateKey());
        map.put("receipt", platMerBaseCode.getBaseCode());
        StringBuilder s = new StringBuilder("");
        map.forEach((k, v) -> s.append(v));

        String sign = SecureUtil.md5(s.toString()).toUpperCase();
        log.info("wykkt launch s {}", s.toString());

        map.remove("key");
        map.put("hmac", sign);
        log.info("wykkt launch md5(s) " + sign);

        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("wykkt launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("wykkt launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("000").equals(jsonObject.getString("code"))) {
            log.info("wykkt launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("obj").getString("h5_url") + "?id=" + jsonObject.getJSONObject("obj").getString("id") + "&userId=" + platMer.getMerKey(), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("wykkt launch return null");
        return null;
    }

    public PayUrl quzhifuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new LinkedHashMap();
        sortedMap.put("fxid", platMer.getMerKey());
        sortedMap.put("fxddh", platMerOrderParam.getOrderId());
        sortedMap.put("fxdesc", "test");
        sortedMap.put("fxfee", String.format("%.2f", platMerOrderParam.getAmount()));
        sortedMap.put("fxnotifyurl", channel.getNotifyUrl());
        sortedMap.put("fxbackurl", "http://www.baidu.com");
        sortedMap.put("fxip", "127.0.0.1");
        sortedMap.put("fxpay", platMerBaseCode.getBaseCode());
        sortedMap.put("fxuserid","1");
        String s = sortedMap.get("fxid").toString() + sortedMap.get("fxddh").toString() + sortedMap.get("fxfee").toString()
                + sortedMap.get("fxnotifyurl").toString() + platMer.getPrivateKey();
        log.info("result a qbf {}", s);
        String sign = SecureUtil.md5(s).toLowerCase();

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("fxsign", sign);
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        String createUrl = channel.getCreateUrl();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getInteger("status").intValue() == 1) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return null;
    }

    public PayUrl yiliaomaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_tradetype", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_callbackurl", channel.getNotifyUrl());
        sortedMap.put("pay_turnyurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100)).intValue())+"");
        sortedMap.put("pay_productname", "test");



        String s = convertUrl(sortedMap, "&", "=");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();
        log.error(s + "&key=" + platMer.getPrivateKey());
        sortedMap.put("signature", sign);
        String createUrl = channel.getCreateUrl();
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getInteger("code").intValue() == 11) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("codeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl huabaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", "c07d514573c641788dded1671916d72a");
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("huaxin launch s " + s);
        log.info("huaxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("huaxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("huaxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("huaxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("huaxin launch return null");
        return null;
    }

    public PayUrl chaofanUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("shid", platMer.getMerKey());
        map.put("key", platMer.getPrivateKey());
        map.put("pay", platMerBaseCode.getBaseCode());
        map.put("orderid", platMerOrderParam.getOrderId());
        map.put("amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("huaxin launch map " + map);

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(map, "&", "=");
        log.info("yingfutong {}", url);

        log.info("yingfutong success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl dingshengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return moqingUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl dmUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String,Object> sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());
        sortedMap.put("pay_is_form", 1);

        String s = convertUrlIsEmptyObject(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("s {}  sign {}", s, sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("pay_md5sign", sign);

        String url = channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(sortedMap, "&", "=");
        log.info("url {}", url);

        log.info("moqingUrl success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl youyifuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String,Object> sortedMap = new TreeMap();
        sortedMap.put("sa", "deposit");
        sortedMap.put("orderNo", platMerOrderParam.getOrderId());
        sortedMap.put("amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        sortedMap.put("payType", platMerBaseCode.getBaseCode());
        sortedMap.put("mchNo", platMer.getMerKey());
        sortedMap.put("remark", "test");
        sortedMap.put("returnUrl", channel.getNotifyUrl());
        sortedMap.put("callbackUrl", channel.getNotifyUrl());

        String s = convertUrlIsEmptyObject(sortedMap, "&", "=") + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("s {}  sign {}", s, sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);

        String url = channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(sortedMap, "&", "=");
        log.info("url {}", url);

        log.info("moqingUrl success");
        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl wangcaiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("customer_id", platMer.getMerKey());
        sortedMap.put("out_order_id", platMerOrderParam.getOrderId());
        sortedMap.put("pay_type", platMerBaseCode.getBaseCode());
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("return_url", channel.getNotifyUrl());
        sortedMap.put("money", platMerOrderParam.getAmount().toString());
        sortedMap.put("from_ip", "127.0.0.1");

        String s = convertUrl(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        log.info(" baichuan s {}", s);

        String sign = SecureUtil.md5(s).toUpperCase();

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);
        sortedMap.put("is_wap", 0);
        log.info(" baichuan launch map " + sortedMap);

        String url = channel.getCreateUrl() + "?" + convertUrlNotEmpty(sortedMap, "&", "=");
        log.info("baichuan url {}", url);

        log.info("baichuan success");

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl longtengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());

        String s = convertUrl(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("s {}  sign {}", s, sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("pay_md5sign", sign);
        sortedMap.put("pay_returnType", "json");
        sortedMap.put("clientip", "127.0.0.1");

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getInteger("status").intValue() == 0000) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("pay_info"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return null;
    }

    public PayUrl longfuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new LinkedHashMap();
        sortedMap.put("fxid", platMer.getMerKey());
        sortedMap.put("fxddh", platMerOrderParam.getOrderId());
        sortedMap.put("fxdesc", "test");
        sortedMap.put("fxfee", platMerOrderParam.getAmount());
        sortedMap.put("fxip", "127.0.0.1");
        sortedMap.put("fxpay", platMerBaseCode.getBaseCode());
        sortedMap.put("fxnotifystyle", 2);
//        sortedMap.put("pay_bankcode", platMerBaseCode.getBankCode());
        sortedMap.put("fxnotifyurl", channel.getNotifyUrl());
        sortedMap.put("fxbackurl", channel.getNotifyUrl());
//        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        String s = sortedMap.get("fxid").toString() + sortedMap.get("fxddh").toString() +
                sortedMap.get("fxfee").toString() + sortedMap.get("fxnotifyurl").toString() + platMer.getPrivateKey();
        log.info("result a qbf {}", s);
        String sign = SecureUtil.md5(s);


        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("fxsign", sign);

        log.info("map {}", sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        String createUrl = channel.getCreateUrl();


        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getInteger("status").intValue() == 1) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payurl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return null;    }

    public PayUrl liuyiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return xiaocaoUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl jinxiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return aqiangUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl huojianUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return binliUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl kaertaobaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        SortedMap sortedMap = new TreeMap();
        sortedMap.put("appId", platMer.getMerKey());
        sortedMap.put("orderNo", platMerOrderParam.getOrderId());
        sortedMap.put("timestamp", System.currentTimeMillis());
        sortedMap.put("money", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        sortedMap.put("noticeUrl", channel.getNotifyUrl());

        String s = platMer.getMerKey() + "^" + platMerOrderParam.getOrderId() + "^" +
                sortedMap.get("money") + "^" + sortedMap.get("timestamp") + "^" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);
        log.info("s {}  sign {}", s, sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getString("result").equals("success")) {

            return new PayUrl(1, channel.getChannelCode(),
                    jsonObject.getJSONObject("data").getString("qrCode"), platMerOrderParam.getOrderId(),
                    true, platMerOrderParam.getAmount());

        }

        return null;
    }


    public PayUrl zhuanqianUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String, Object> sortedMap = new LinkedHashMap<>();
        sortedMap.put("uid", platMer.getMerKey());
        sortedMap.put("pay_type", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_id", "");
        sortedMap.put("group_id", 0);
        sortedMap.put("goods_name", "goodname");
        sortedMap.put("order_id", platMerOrderParam.getOrderId());
        sortedMap.put("price", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        sortedMap.put("exact", false);
        sortedMap.put("sign_type", "sha1");
        sortedMap.put("notify_url", channel.getNotifyUrl());

        StringBuilder sb = new StringBuilder();
        sortedMap.forEach((k, v) -> {
            sb.append(v);
        });
        String s = sb.append(platMer.getPrivateKey()).toString();
        String sign = this.encode(s);

        log.info("s {}  sign {}", s, sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);

        log.info("map {}", sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getString("success").equals("true")) {

            return new PayUrl(1, channel.getChannelCode(),
                    jsonObject.getString("qrcode"), platMerOrderParam.getOrderId(),
                    true, platMerOrderParam.getAmount());

        }

        return null;
    }

    private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
            'e', 'f' };

    /**
     * Takes the raw bytes from the digest and formats them correct.
     *
     * @param bytes
     *            the raw bytes from the digest.
     * @return the formatted bytes.
     */
    private static String getFormattedText(byte[] bytes) {
        int len = bytes.length;
        StringBuilder buf = new StringBuilder(len * 2);
        // 把密文转换成十六进制的字符串形式
        for (int j = 0; j < len; j++) {
            buf.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]);
            buf.append(HEX_DIGITS[bytes[j] & 0x0f]);
        }
        return buf.toString();
    }

    public static String encode(String str) {
        if (str == null) {
            return null;
        }
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("SHA1");
            messageDigest.update(str.getBytes());
            return getFormattedText(messageDigest.digest());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public PayUrl shiliuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return zfbUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl congzhongUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return dingshunUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl huitongUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam
            platMerOrderParam, MerChannel channel) {
        return luoyaoUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl dongyaziyingUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam
            platMerOrderParam, MerChannel channel) {
        return luoyaoUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl chengzi2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return zhuanqianUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl kcUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return zhuanqianUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl yuxinUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return zhuanqianUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }


    public PayUrl uu898Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("amount", platMerOrderParam.getAmount());
        sortedMap.put("jfOrderId", platMerOrderParam.getOrderId());
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("map {}", sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result {}", body);
        if (jsonObject.getInteger("status").intValue() == 1) {
            log.info("success");
            return new PayUrl(7, channel.getChannelCode(), jsonObject.getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return null;
    }

    public PayUrl uu898CallbackUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws Exception {
        String orderId = platMerOrderParam.getOrderId();
        BigDecimal amount = platMerOrderParam.getAmount();

        Map<String, Object> sortedMap = new HashMap<>();
        sortedMap.put("amount", amount);
        sortedMap.put("jfOrderId", orderId);

        PlatMerOrder byOrderId = platMerOrderService.getByOrderId(orderId);

        if (byOrderId.getAmount().doubleValue() != amount.doubleValue()) {
            int b = platMerOrderService.success(byOrderId);
            if (b > 0) {
                report(byOrderId);
                log.info("success");
            }
        }

        log.info("baichuan success");

        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" +
                convertUrlNotEmpty(sortedMap, "&", "="), platMerOrderParam.getOrderId(),
                true, platMerOrderParam.getAmount());
    }

    public void report(PlatMerOrder platMerOrder) {
        if (platMerOrder.getMerId() == null) {
            return;
        }
        if (platMerOrder.getPlatMerFee() == null) {
            platMerOrder.setPlatMerFee(new BigDecimal(0));
        }

        PlatChannelReport platChannelReport = new PlatChannelReport();
        platChannelReport.setPlatFee(String.valueOf(platMerOrder.getPlatMerFee().doubleValue()));
        platChannelReport.setChannelCode(platMerOrder.getChannelCode());

        if (platMerOrder.getRealAmount() == null) {


            platChannelReport.setAmount(platMerOrder.getAmount());
        } else {
            platChannelReport.setAmount(platMerOrder.getRealAmount());
        }

        platChannelReport.setTotalAmount(new BigDecimal(0));

        platChannelReport.setChannelMerId(platMerOrder.getMerId());
        platChannelReport.setCreateDate(platMerOrder.getCreatedAt());
        platChannelReport.setReportDate(platMerOrder.getCreatedAt());
        platChannelReport.setPlatCode(platMerOrder.getPlatCode());
        platChannelReport.setChannelMerId(platMerOrder.getMerId());
        platChannelReport.setTotalPlatFee(new BigDecimal(0));
        platChannelReport.setTotalCount(0);
        platChannelReport.setTotalSucceedCount(1);
        platChannelReport.setOrderOrginFee(platMerOrder.getOrginCustFee());
        platChannelService.updateReport(platChannelReport);
    }

    public PayUrl changjiangdingshunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("pid", platMer.getMerKey());
        sortedMap.put("money", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        sortedMap.put("sn", platMerOrderParam.getOrderId());
        sortedMap.put("pay_type", platMerBaseCode.getBaseCode());
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("callback_url", channel.getNotifyUrl());
        sortedMap.put("pay_date", System.currentTimeMillis()/1000);

        String s = convertUrlIsEmptyObject(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("s {}  sign {}", s, sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getInteger("code").intValue() == 1) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("code_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return null;
    }

    public PayUrl subaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return aqiangUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl jfUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String, Object> sortedMap = new LinkedHashMap<>();
        sortedMap.put("pay_amount", platMerOrderParam.getAmount());
        sortedMap.put("pay_applydate", new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_callbackurl", channel.getNotifyUrl());
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());

        String s = convertUrlIsEmptyObject(sortedMap, "&", "=") + "&key=" + platMer.getPrivateKey();

        String sign = SecureUtil.md5(s).toUpperCase();

        sortedMap.put("pay_md5sign", sign);
        sortedMap.put("pay_attach", "");
        sortedMap.put("pay_productname", "测试商品");
        sortedMap.put("pay_productnum", 1);
        sortedMap.put("pay_productdesc", "");
        sortedMap.put("pay_producturl", "");

        log.info("hongYi s " + s);
        log.info("hongYi sign " + sign);
        log.info("hongYi map " + sortedMap);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("body info data hongYi {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (jsonObject.getInteger("code").intValue() == 200) {
            log.info("hongYi success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("hongYi return null");
        return null;
    }

    public PayUrl kaer3Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return aqiangUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl kupaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("version", "v1.0");
        sortedMap.put("serviceType", "qrcodeReceipt");
        sortedMap.put("signType", "md5");
        sortedMap.put("merNo", platMer.getMerKey()  );
        sortedMap.put("requestNo", "20190428020102101974");
        sortedMap.put("merOrderNo", platMerOrderParam.getOrderId());
        sortedMap.put("payType", platMerBaseCode.getBaseCode());
        sortedMap.put("tradeAmt", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        sortedMap.put("notifyUrl", channel.getNotifyUrl());

        String s = convertUrlNotEmpty(sortedMap, "&", "=") + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toLowerCase();
        log.info("s {}  sign {}", s, sign);

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("signature", sign);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if ("P000".equals(jsonObject.getString("respCode"))) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("qrCodeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return null;
    }

    public PayUrl huiteng2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> signData = new TreeMap();
        signData.put("pay_memberid", platMer.getMerKey());
        signData.put("pay_orderid", platMerOrderParam.getOrderId());

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        signData.put("pay_applydate", simpleDateFormat.format(platMerOrderParam.getCreatedAt()));
        signData.put("pay_bankcode", platMerBaseCode.getBaseCode());
        signData.put("pay_notifyurl", channel.getNotifyUrl());
        signData.put("pay_callbackurl", channel.getNotifyUrl());
        signData.put("pay_amount", platMerOrderParam.getAmount());
        String s = convertUrlNotEmpty(signData, "&", "=");


        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&key=" + platMer.getPrivateKey());

        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();
//        signData.put("pay_productname","goods");
        String createUrl = channel.getCreateUrl();

        String url = createUrl + "?" + s + "&pay_productname=good&pay_md5sign=" + sign ;
        log.info("url {}", url);

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

    }

    public PayUrl guangsuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return dongyaYihaoPayUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl miaofuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", new DecimalFormat("0").format((platMerOrderParam.getAmount().multiply(new BigDecimal(100))).doubleValue()));
//        map.put("clientIp", "34.80.174.100");
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
//        map.put("extra", "{ \"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }

    public PayUrl longjuanfengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("mch_id", platMer.getMerKey());
        sortedMap.put("ptype", platMerBaseCode.getBaseCode());
        sortedMap.put("order_sn", platMerOrderParam.getOrderId());
        sortedMap.put("money", String.format("%.2f", platMerOrderParam.getAmount()));
        sortedMap.put("goods_desc", "good");
        sortedMap.put("client_ip", "127.0.0.1");
        sortedMap.put("format", "page");
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("time", (System.currentTimeMillis() / 1000) + "");


        String s = convertUrlIsEmptyObject(sortedMap, "&", "=");


        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&key=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toLowerCase();

        sortedMap.put("sign", sign);


        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(sortedMap, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }


    public PayUrl epayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("merCode", platMer.getMerKey());
        map.put("saveWayCode", platMerBaseCode.getBaseCode());
        map.put("bankCode", platMerBaseCode.getBaseCode());
        map.put("amount", String.format("%.2f", platMerOrderParam.getAmount()));
        map.put("merOrderId", platMerOrderParam.getOrderId());
        map.put("notifyUrl", channel.getNotifyUrl());


        log.error("jinshunfu {}", convertUrlNotEmpty(map, "&", "="));
        String sign = SecureUtil.md5(convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey()).toLowerCase();

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("qmpay launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("qmpay launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("rechargeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        return null;
    }

    public PayUrl yuanwang2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return yuanwangUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl qiantongUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("payKey", platMer.getMerKey());
        map.put("orderPrice", String.format("%.2f", platMerOrderParam.getAmount()));
        map.put("outTradeNo", platMerOrderParam.getOrderId());
        map.put("productType", platMerBaseCode.getBaseCode());
        map.put("orderTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
        map.put("productName", "test");
        map.put("orderIp", "127.0.0.1");
        map.put("userId", UUID.randomUUID().toString());
        map.put("returnUrl", channel.getNotifyUrl());
        map.put("notifyUrl", channel.getNotifyUrl());

        String s = convertUrlNotEmpty(map, "&", "=");

        log.error("jinshunfu {}", s);
        String sign = SecureUtil.md5(s + "&paySecret=" + platMer.getPrivateKey()).toUpperCase();

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("sign {}", sign);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("qmpay launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("0000").equals(jsonObject.getString("resultCode"))) {
            log.info("qmpay launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("payMessage"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        return null;
    }

    public PayUrl liantongUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return wuyueUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl xiangyunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("partner", platMer.getMerKey());
        map.put("service", platMerBaseCode.getBaseCode());
        map.put("tradeNo", platMerOrderParam.getOrderId());
        map.put("amount", platMerOrderParam.getAmount());
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("resultType", "json");
        map.put("extra", "test");
        String s = convertUrlNotEmpty(map, "&", "=")+ "&" + platMer.getPrivateKey();

        log.error("jinshunfu {}", s);
        String sign = SecureUtil.md5(s );
        log.info("sign {}", sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("sign {}", sign);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("qmpay launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("T").equals(jsonObject.getString("isSuccess"))) {
            log.info("qmpay launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        return null;
    }

    public PayUrl kuaifutongUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("mch_id", platMer.getMerKey());
        map.put("trade_id", platMerOrderParam.getOrderId());
        map.put("ip", "127.0.0.1");
        map.put("fee", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        map.put("pay_type", platMerBaseCode.getBaseCode());
        map.put("notify_url", channel.getNotifyUrl());

        String s = platMer.getPrivateKey() + convertUrlNotEmpty(map, "&", "=") + platMer.getPrivateKey();

        log.error("jinshunfu {}", s);
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("sign {}", sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("sign {}", sign);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("qmpay launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("0").equals(jsonObject.getString("errCode"))) {
            log.info("qmpay launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        return null;
    }

    public PayUrl haifengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws UnsupportedEncodingException {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))).intValue());
        map.put("clientIp", "34.80.174.100");
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("extra", "{ \"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        log.info("jinxin launch map " + map);


//        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("map {}", map);

        String url =  channel.getRealUrl() + convertUrlNotEmpty(map, "&", "=");
        log.info("http {}", channel.getRealUrl() + url);

        log.error(channel.getRealUrl()+"?params="+URLEncoder.encode(JSONObject.toJSONString(map)));
        String body = HttpUtil.createPost(channel.getRealUrl()+"?params="+URLEncoder.encode(JSONObject.toJSONString(map))).execute().body();
        log.error(body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("jinxin launch success");
            log.info("jsonObject.getJSONObject(\"payParams\") {}", jsonObject.getJSONObject("payParams"));
            log.info("str {}", jsonObject.getJSONObject("payParams").getString("payUrl"));
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;    }

    public PayUrl juli2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws UnsupportedEncodingException {
        Map<String, Object> map1 = new HashMap<>();
        map1.put("total_fee", platMerOrderParam.getAmount());
        map1.put("order_sn", platMerOrderParam.getOrderId());
        map1.put("goods", "test");
        map1.put("user_id", UUID.randomUUID().toString().replace("-", ""));
        map1.put("pay_type", platMerBaseCode.getBaseCode());
        map1.put("notify_url", channel.getNotifyUrl());
        map1.put("return_url", channel.getNotifyUrl());

        Map<String, Object> map = new TreeMap();
        map.put("mch_id", platMer.getMerKey());
        map.put("method", "shop.payment.transferPayH5");
        map.put("version", "1.0");
        map.put("timestamp", System.currentTimeMillis());
        map.put("content", JSONObject.toJSONString(map1));

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("true").equals(jsonObject.getString("success"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;    }

    public PayUrl bUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws UnsupportedEncodingException {
        Map<String, Object> querys = new TreeMap<>();
        querys.put("orderid", platMerOrderParam.getOrderId());
        querys.put("type", platMerBaseCode.getBaseCode());
        querys.put("money", platMerOrderParam.getAmount());
        querys.put("attach", "test");
        querys.put("bank_code", 1001);
        querys.put("ip", "127.0.0.1");
        querys.put("callbackurl", channel.getNotifyUrl());
        querys.put("notifyurl", channel.getNotifyUrl());

        String s = convertUrlNotEmpty(querys, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);

        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        querys.put("sign", sign);
//        querys.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + querys);

        String url = channel.getRealUrl() + "?" + convertUrlNotEmpty(querys, "&", "=");

        log.info(url);

        String body = HttpUtil.createPost(url).header("token", platMer.getMerKey()).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("status_code"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;    }


    public PayUrl kk2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws UnsupportedEncodingException {
        Map<String, Object> querys = new TreeMap<>();
        querys.put("merch_id", platMer.getMerKey());
        querys.put("product", platMerBaseCode.getBaseCode());
        querys.put("order_id", platMerOrderParam.getOrderId());
        querys.put("amount", platMerOrderParam.getAmount());
        querys.put("notify_url", channel.getNotifyUrl());

        String s = convertUrlNotEmpty(querys, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);

        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        querys.put("sign", sign);
        querys.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + querys);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(querys).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);

        log.info("jinxin launch body {}", body);
        if (("success").equals(jsonObject.getString("code"))) {
            log.info("jinxin launch success");
            String url = jsonObject.getString("pay_url").replace("\\", "");
            log.info("url {}", url);
            return new PayUrl(1, channel.getChannelCode(), url,
                    platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;    }


    public PayUrl liantongkamiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return wuyueUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl tianyuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
    	
    	
    	Map sortedMap = new LinkedHashMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());
        sortedMap.put("pay_applydate", DateUtil.format(new Date(), "yyyyMMddHHmmss"));
        sortedMap.put("pay_channelCode", platMerBaseCode.getBaseCode());
//        sortedMap.put("pay_bankcode", platMerBaseCode.getBankCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
//        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());

        String s = convertUrl(sortedMap, "&", "^");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        log.info("s  {}", s);
        s = convertUrl(sortedMap, "&", "=") + "&pay_md5sign=" + sign;
        String createUrl = channel.getCreateUrl();

        log.info("url {}", createUrl + "?" + s);

        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
//        return jinZhiFuUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }//b2cShangtian
    public PayUrl b2cShangtianUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("amount", platMerOrderParam.getAmount());
        sortedMap.put("jfOrderId", platMerOrderParam.getOrderId());
 sortedMap.put("orderId", platMerOrderParam.getOrderId());
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("map {}", sortedMap);

        String body = HttpUtil.createPost(channel.getRealUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result {}", body);
        if (jsonObject.getInteger("status").intValue() == 1) {
            log.info("success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return null;
    }

    public PayUrl longjuanfeng2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws UnsupportedEncodingException {
        Map<String, Object> querys = new LinkedHashMap<>();
        querys.put("amount", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        querys.put("code", platMer.getPrivateKey());
        querys.put("orderNumber", platMerOrderParam.getOrderId());
        querys.put("notifyurl", channel.getNotifyUrl());
        querys.put("type", platMerBaseCode.getBaseCode());

        querys.put("key", platMer.getMerKey());

        String s = JSON.toJSONString(querys);
        String sign = SecureUtil.md5(s);

        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        querys.put("token", sign);
        querys.put("urlType", 2);
        querys.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + querys);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(querys).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);

        log.info("jinxin launch body {}", body);
        if (("1").equals(jsonObject.getString("state"))) {
            log.info("jinxin launch success");
            String url = jsonObject.getString("msg");
            log.info("url {}", url);
            return new PayUrl(1, channel.getChannelCode(), url,
                    platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;    }


    public PayUrl svipUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map sortedMap = new TreeMap();
        sortedMap.put("user_account", platMer.getMerKey());
        sortedMap.put("out_trade_no", platMerOrderParam.getOrderId());
        sortedMap.put("payment_type", platMerBaseCode.getBaseCode());
        sortedMap.put("total_fee", platMerOrderParam.getAmount().toString());
        sortedMap.put("trade_time", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("return_url", channel.getNotifyUrl());
        sortedMap.put("body", "test");

        String s = convertUrl(sortedMap, "&", "=");
        log.info("s {}", s);

        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();
        log.error("sign is error {}", sign);

        s = convertUrl(sortedMap, "&", "=") + "&sign=" + sign;

        String createUrl = channel.getCreateUrl();

        String url = createUrl + "?" + s;

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl pikaqiuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return juziPayUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl kaerhongbaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return svipUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl tudou2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("appid", platMer.getMerKey());
        map.put("pay_type", platMerBaseCode.getBaseCode());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("callback_url", channel.getNotifyUrl());
        map.put("success_url", channel.getNotifyUrl());
        map.put("error_url", channel.getNotifyUrl());
        map.put("out_uid", "15017399440");
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("version", "v1.1");
        log.info(" pilin map " + map);
//        map.put("return_type", "app");
        StringBuilder s = new StringBuilder("");
        for (String key : map.keySet()) {
            if (null != map.get(key) && !"".equals(map.get(key))) {
                s.append(key).append("=").append(map.get(key)).append("&");
            }
        }
        s.append("key").append("=").append(platMer.getPrivateKey());
        log.info("zfb s " + s);

        String md5Str = SecureUtil.md5(s.toString()).toUpperCase();
        log.info(" zfb md5Str " + md5Str);

        map.put("sign", md5Str);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("zfb pilin map " + map);

//        return new PayUrl(1, channel.getChannelCode(), channel.getCreateUrl() + "?" + convertUrlIsEmptyObject(map, "&", "="), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("zfb launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("zfb launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("qrcode"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("zfb launch error");
        return null;    }

    public PayUrl yifuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws UnsupportedEncodingException {
        Map<String, Object> querys = new TreeMap<>();
        querys.put("merchant_id", platMer.getMerKey());
        querys.put("order_id", platMerOrderParam.getOrderId());
        querys.put("amount", platMerOrderParam.getAmount().multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)));
        querys.put("pay_type", platMerBaseCode.getBaseCode());
        querys.put("notify_url", channel.getNotifyUrl());
        querys.put("user_id", UUID.randomUUID().toString().replace("-", ""));
        querys.put("user_ip", "127.0.0.1");


        String s = convertUrlNotEmpty(querys, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s);

        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        querys.put("sign", sign);
        querys.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + querys);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(querys).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);

        log.info("jinxin launch body {}", body);
        if (("0").equals(jsonObject.getString("code"))) {
            log.info("jinxin launch success");
            String url = jsonObject.getJSONObject("data").getString("pay_url");
            log.info("url {}", url);
            return new PayUrl(1, channel.getChannelCode(), url,
                    platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;    }

    public PayUrl jubaopenUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws UnsupportedEncodingException {
        Map<String, Object> querys = new TreeMap<>();
        querys.put("price", new DecimalFormat("0.00").format(platMerOrderParam.getAmount()));
        querys.put("type", platMerBaseCode.getBaseCode());
        querys.put("payId", platMerOrderParam.getOrderId());
        querys.put("notifyUrl", channel.getNotifyUrl());
        querys.put("returnUrl", channel.getNotifyUrl());
        querys.put("isHtml", 1);
        querys.put("param", platMer.getMerKey());

        log.info("before map {}", querys);

        String s = SecureUtil.md5(querys.get("payId").toString() + querys.get("param").toString() +
                querys.get("type").toString() + querys.get("price").toString() + platMer.getPrivateKey());

        log.info("jinxin launch s " + s);

        querys.put("sign", s);
        querys.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + querys);

        s = convertUrlNotEmpty(querys, "&", "=") + "&sign=" + s;

        String createUrl = channel.getCreateUrl();

        String url = createUrl + "?" + s;

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

//        String body = HttpUtil.createPost(channel.getCreateUrl()).form(querys).execute().body();
//        JSONObject jsonObject = JSONObject.parseObject(body);
//
//        log.info("jinxin launch body {}", body);
//        if (("1").equals(jsonObject.getString("code"))) {
//            log.info("jinxin launch success");
//            String url = jsonObject.getJSONObject("data").getString("payUrl");
//            log.info("url {}", url);
//            return new PayUrl(1, channel.getChannelCode(), url,
//                    platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
//        }
//
//        log.info("jinxin launch return null");
//        return null;
    }

    public PayUrl youziUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("merchantId", platMer.getMerKey());
        map.put("tradeNo", platMerOrderParam.getOrderId());
        map.put("amount", platMerOrderParam.getAmount().intValue());
        map.put("applyDate", DateUtil.format(new Date(), "yyyy-MM-dd hh:mm:ss"));
        map.put("channelType", platMerBaseCode.getBaseCode());
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("memberId", UUID.randomUUID().toString().replace("-", ""));

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();

        log.info("qianjinfu launch s" + s);

        String sign = SecureUtil.md5(s);
        log.info("qianjinfu launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("qianjinfu launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("qianjinfu launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("1".equals(jsonObject.getString("code"))) {
            log.info("qianjinfu launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("qianjinfu error");
        return null;
    }

    public PayUrl huitong2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam
            platMerOrderParam, MerChannel channel) {
        return luoyaoUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl suixingUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("Version", "1.0");
        map.put("MerNo", platMer.getMerKey());
        map.put("PayType", platMerBaseCode.getBaseCode());
        map.put("TxSN", platMerOrderParam.getOrderId());
        map.put("Amount", platMerOrderParam.getAmount().multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)).intValue());
        map.put("PdtName", "tst");
        map.put("UserId", UUID.randomUUID().toString().replace("-", ""));
        map.put("UserIp", "127.0.0.1");
        map.put("NotifyUrl", channel.getNotifyUrl());
        map.put("ReqTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));

        String s = convertUrlNotEmpty(map, "&", "=") + platMer.getPrivateKey();
        log.info("suixingUrl s {}" + s);

        String sign = SecureUtil.md5(s);
        log.info("suixingUrl sign {}", sign);

        map.put("SignMethod", "MD5");
        map.put("Signature", sign);

        log.info("suixingUrl map {}", map);

        String jsonStr = JSON.toJSONString(map);
        log.info("suixingUrl map {}", jsonStr);

        jsonStr = cn.hutool.core.codec.Base64.encode(jsonStr);
        log.info("jsonStr {}", jsonStr);

        jsonStr = jsonStr.replace("+", "%2B");

        Map<String, Object> requestMap = new HashMap<>();
        requestMap.put("tfTsData", jsonStr);

        log.info("map {}", requestMap);
        log.info("realUrl {}", channel.getRealUrl());

        log.info("request {}", JSON.toJSONString(requestMap));

        String requestStr = "tfTsData=" + jsonStr;
        log.info("1 {}", requestStr);

        String body = HttpUtil.createPost(channel.getRealUrl()).body(requestStr).execute().body();

        log.info("suixingUrl body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("1".equals(jsonObject.getString("Status"))) {
            log.info("suixingUrl success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("PayUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("suixingUrl error");
        return null;
    }

    public PayUrl xyUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("appid", platMer.getMerKey());
        map.put("price", platMerOrderParam.getAmount().multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)).intValue());
        map.put("order_sn", platMerOrderParam.getOrderId());
        log.info(platMer.getMerKey() + map.get("price") + map.get("order_sn") + platMer.getPrivateKey());
        String s = SecureUtil.md5(
                SecureUtil.md5(platMer.getMerKey() + map.get("price") + map.get("order_sn") + platMer.getPrivateKey())
        );

        log.info("qianjinfu launch s" + s);


        map.put("sign", s);
        map.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("qianjinfu launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();

        log.info("qianjinfu launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if ("1".equals(jsonObject.getString("code"))) {
            log.info("qianjinfu launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("qianjinfu error");
        return null;
    }

    public PayUrl ncgepay2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map signData = new TreeMap();
        signData.put("ip", "127.0.0.1");

        signData.put("merchantNo", platMer.getMerKey());
        signData.put("money", String.format("%.2f", platMerOrderParam.getAmount()));
        signData.put("notify", channel.getNotifyUrl());
        signData.put("out_trade_no", platMerOrderParam.getOrderId());
        signData.put("pay", platMerBaseCode.getBaseCode());

        String s = convertUrlIsEmpty(signData, "&", "=")+ "&secret=" + platMer.getPrivateKey();


        String sign = SecureUtil.md5(s ).toUpperCase();

        log.info("s {}", s);
        log.info("sign {}", sign);

        String createUrl = channel.getRealUrl()+ "?" + convertUrl(signData, "&", "=") + "&sign=" + sign;

        log.info("url {}", createUrl);

        String body = HttpUtil.createPost(createUrl).execute().body();

        log.info("body {}", body);

        JSONObject jsonObject = JSONObject.parseObject(body);
        log.error(" response ao pay {}", jsonObject.toJSONString());
        if (jsonObject.getInteger("code").intValue() == 200) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return null;
    }

    public PayUrl feifanUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return kuaizhifuUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl chaojifuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return binliUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl hx2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws UnsupportedEncodingException {
        // 11111111
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("clientIp", "127.0.0.1");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        log.info("jinxin launch map " + map);

        String param = JSON.toJSONString(map);
        String enco = URLEncoder.encode(param, "utf-8");
        log.info("hx param {}  : enco {}", param, enco);

        log.info("url {}", channel.getRealUrl());

        Map<String, Object> data = new TreeMap();
        data.put("params", enco);

        String body = HttpUtil.createGet(channel.getRealUrl()).form(data).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("codeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;    }

    public PayUrl chuangxinUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> business = new TreeMap<>();
        business.put("service", "service.ffff.pay");
        business.put("merchant_id", platMer.getMerKey());
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        business.put("request_time", simpleDateFormat.format(new Date()));
        business.put("nonce_str", UUID.randomUUID().toString().replaceAll("-", ""));
        business.put("version", "V1.1");
//        business.put("sign_type", "MD5");


        Map<String, Object> data = new TreeMap<>();
        data.put("order_no", platMerOrderParam.getOrderId());
        DecimalFormat df = new DecimalFormat("0.00");
        data.put("amount", df.format(platMerOrderParam.getAmount()));
        data.put("notify_url", channel.getNotifyUrl());
        data.put("return_url", channel.getNotifyUrl());
        data.put("currency", "CNY");
        data.put("trade_code", platMerBaseCode.getBaseCode());
        data.put("client_ip", "127.0.0.1");
        data.put("terminal_type", "pc");

        Map<String, Object> sort = new TreeMap<>();
        sort.putAll(business);
        sort.putAll(data);
        log.info("sign map {}", sort);

        String s = convertUrlIsEmptyObject(sort, "&", "=") + "&key=" + platMer.getPrivateKey();

        log.error("jjzhifu url md5 {}", s);
        business.put("sign_type", "MD5");
        business.put("sign", SecureUtil.md5(s).toUpperCase());
        business.put("data", data);


        log.info("map {}", business);

        String body = HttpUtil.createPost(channel.getRealUrl()).header("Content-Type", "application/json").body(JSONObject.toJSONString(business)).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);

        log.info("result a jjzhifu {}", body);
        if (jsonObject.getInteger("resp_code").intValue() == 1000) {
            log.info("success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_info"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }
        return null;    }

     public PayUrl huibaoUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return stormUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl yifanUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws UnsupportedEncodingException {
        Map<String, Object> querys = new TreeMap<>();
        querys.put("amt", platMerOrderParam.getAmount().multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)));
        querys.put("appOrder", platMerOrderParam.getOrderId());
        querys.put("appid", platMer.getMerKey());
        querys.put("type", platMerBaseCode.getBaseCode());
        querys.put("notifyUrl", channel.getNotifyUrl());
        querys.put("returnUrl", channel.getNotifyUrl());
        querys.put("merchantIp", "127.0.0.1");

StringBuffer a = new StringBuffer();
        for (Map.Entry<String, Object> entry : querys.entrySet()) {
            a.append(entry.getValue());
        }
        String s = a.toString() + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();

        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        querys.put("sign", sign);
        querys.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + querys);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(querys).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);

        log.info("jinxin launch body {}", body);
        if (("1000").equals(jsonObject.getString("code"))) {
            log.info("jinxin launch success");
            String url = jsonObject.getJSONObject("data").getString("url");
            log.info("url {}", url);
            return new PayUrl(1, channel.getChannelCode(), url,
                    platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;    }

    public PayUrl longzhifuUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return binliUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl mudanUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {


        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("mch_id", platMer.getMerKey());
        sortedMap.put("ptype", platMerBaseCode.getBaseCode());
        sortedMap.put("order_sn", platMerOrderParam.getOrderId());
        sortedMap.put("money", String.format("%.2f", platMerOrderParam.getAmount()));
        sortedMap.put("goods_desc", "good");
        sortedMap.put("client_ip", "127.0.0.1");
        sortedMap.put("format", "json");
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("time", (System.currentTimeMillis() / 1000) + "");


        String s = convertUrlIsEmptyObject(sortedMap, "&", "=");


        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&key=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toLowerCase();
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());

        sortedMap.put("sign", sign);

        log.info("map {}", sortedMap);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);

        log.info("jinxin launch body {}", body);
        if (("1").equals(jsonObject.getString("code"))) {
            log.info("jinxin launch success");
            String url = jsonObject.getJSONObject("data").getString("qrcode");
            log.info("url {}", url);
            return new PayUrl(1, channel.getChannelCode(), url,
                    platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }

    public PayUrl ncnewverUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map signData = new TreeMap();
        signData.put("merchantNo", platMer.getMerKey());
        signData.put("money", String.format("%.2f", platMerOrderParam.getAmount()));
        signData.put("out_trade_no", platMerOrderParam.getOrderId());
        signData.put("pay", platMerBaseCode.getBaseCode());
        signData.put("notify", channel.getNotifyUrl());
        signData.put("ip", "127.0.0.1");



        String s = convertUrlIsEmpty(signData, "&", "=")+ "&secret=" + platMer.getPrivateKey();
        log.info("s {}", s);


        String sign = SecureUtil.md5(s ).toUpperCase();


        log.info("map {}", signData);

        String createUrl =  channel.getCreateUrl() + "?" + convertUrl(signData, "&", "=") + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign;
        log.info("url {}", createUrl);
        String body = HttpUtil.createGet(createUrl).execute().body();

        JSONObject jsonObject = JSONObject.parseObject(body);
        log.error(" response ao pay {}", jsonObject.toJSONString());
        if (jsonObject.getInteger("code").intValue() == 200) {

            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }
        return null;    }

    public PayUrl youyifu2Url(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        return binliUrl(platMer, platMerBaseCode, platMerOrderParam, channel);
    }

    public PayUrl yunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> signData = new TreeMap();
        signData.put("appkey", platMer.getMerKey());

        signData.put("tradeName", "test");
        signData.put("amount", platMerOrderParam.getAmount().doubleValue() + "");
        signData.put("userOrder", platMerOrderParam.getOrderId());


        String token = platMer.getPrivateKey() +  new SimpleDateFormat("yyyyMMddHH").format(new Date());
        log.info("token {}", token);

        signData.put("token", SecureUtil.md5(token));
        signData.put(Epay.REAL_URL, channel.getRealUrl());

        log.info("map {}", signData);

//        signData.put("pay_productname","goods");
        String createUrl = channel.getCreateUrl();

        String url = createUrl + "?" + convertUrlNotEmpty(signData, "&","=") ;
        log.info("url {}", url);

        return new PayUrl(1, channel.getChannelCode(), url, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());


    }
    public PayUrl chengfengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map<String, Object> business = new TreeMap<>();
        business.put("service", "service.ffff.pay");
        business.put("merchant_id", platMer.getMerKey());
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        business.put("request_time", simpleDateFormat.format(new Date()));
        business.put("nonce_str", UUID.randomUUID().toString().replaceAll("-", ""));
        business.put("version", "V1.0");
//        business.put("sign_type", "MD5");


        Map<String, Object> data = new TreeMap<>();
        data.put("order_no", platMerOrderParam.getOrderId());
        DecimalFormat df = new DecimalFormat("0.00");
        data.put("amount", df.format(platMerOrderParam.getAmount()));
        data.put("notify_url", channel.getNotifyUrl());
        data.put("return_url", channel.getNotifyUrl());
        data.put("currency", "CNY");
        data.put("trade_code", platMerBaseCode.getBaseCode());
        data.put("client_ip", platMerOrderParam.getClientIp());
        data.put("terminal_type", "pc");

        Map<String, Object> sort = new TreeMap<>();
        sort.putAll(business);
        sort.putAll(data);
        log.info("sign map {}", sort);

        String s = convertUrlIsEmptyObject(sort, "&", "=") + "&key=" + platMer.getPrivateKey();

        log.error("jjzhifu url md5 {}", s);
        business.put("sign_type", "MD5");
        business.put("sign", SecureUtil.md5(s).toUpperCase());
        business.put("data", data);


        log.info("map {}", business);
        String createUrl =  channel.getRealUrl() ;
        String body = HttpUtil.createPost(createUrl).body(JSONObject.toJSONString(business)).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);

        log.info("result a jjzhifu {}", body);
        if (jsonObject.getInteger("resp_code").intValue() == 1000) {
            log.info("success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_info"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }
        return null;

    }


    public PayUrl fengyunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {

        Map signData = new TreeMap();
        signData.put("mch_code", platMer.getMerKey());
        signData.put("mch_order_id", platMerOrderParam.getOrderId());
        signData.put("order_type", platMerBaseCode.getBaseCode());
        signData.put("order_amount", String.format("%.2f", platMerOrderParam.getAmount()));
        signData.put("callback_url", channel.getNotifyUrl());
        signData.put("notify_url", channel.getNotifyUrl());
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd HHmmss");
        signData.put("order_time", simpleDateFormat.format(new Date()));
//        platMerOrderParam.setClientIp("58.69.82.81");//
        signData.put("user_ip",platMerOrderParam.getClientIp().split(",")[0].trim());


        simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
        String s = convertUrlIsEmpty(signData, "&", "=")+ "&" + platMer.getPrivateKey()+ "&" +simpleDateFormat.format(new Date());
        log.info("fengyunUrl {}", s);


        String sign = SecureUtil.md5(s ).toLowerCase();


        log.info("map {}", signData);

        signData.put("sign",sign);
        String createUrl =  channel.getRealUrl() ;
        log.info("url {}", createUrl);


        String body = HttpUtil.createPost(createUrl).form(signData).execute().body();

        JSONObject jsonObject = JSONObject.parseObject(body);
        log.error(" response fengyunUrl pay {}", jsonObject.toJSONString());

        return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

    }




    public PayUrl fuyouPayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) throws  Exception {
        Map<String, Object> map = new TreeMap<>();
        map.put("appid", platMer.getMerKey());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        map.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        map.put("callback_url", channel.getNotifyUrl());
        map.put("success_url", channel.getNotifyUrl());
        map.put("error_url", channel.getNotifyUrl());
        map.put("out_uid", "15017399440");
        map.put("out_trade_no", platMerOrderParam.getOrderId());
        map.put("version", "v1.1");
        log.info(" pilin map " + map);
        map.put("return_type", "");
        StringBuilder s = new StringBuilder("");
        for (String key : map.keySet()) {
            if (null != map.get(key) && !"".equals(map.get(key))) {
                s.append(key).append("=").append(map.get(key)).append("&");
            }
        }
        s.append("key").append("=").append(platMer.getPrivateKey());
        log.info("pilin s " + s);

        String md5Str = SecureUtil.md5(s.toString()).toUpperCase();
        log.info(" pilin md5Str " + md5Str);

        map.put("sign", md5Str);
        log.info("pilin pilin map " + map);

        String body = HttpUtil.createPost(channel.getRealUrl()).form(map).execute().body();
        log.info("shangshangkejiPayUrl launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("kaijia launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        throw new Exception("create shangshangkejiPayUrl error");
    }
    public PayUrl qingwaUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", platMer.getPublicKey());
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", ((platMerOrderParam.getAmount().multiply(new BigDecimal(100))).intValue())+"");
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("clientIp", platMerOrderParam.getClientIp().split(",")[0].trim());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("extra", "{\"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
//        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getRealUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }



    public PayUrl zhaocaiUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("user_id", platMer.getMerKey());
        map.put("out_order_no", platMerOrderParam.getOrderId());

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        map.put("pay_time",  simpleDateFormat.format(new Date()));
        map.put("type",  platMerBaseCode.getBaseCode());
        map.put("back_url", channel.getNotifyUrl());
       
        map.put("amount", String.format("%.2f", platMerOrderParam.getAmount()));
        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);
        map.put("pay_json", "1");
        map.put("sign", sign);
        // map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getRealUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("errCode"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }
    public PayUrl dingPayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
    	 Map<String, Object> map = new TreeMap();
         map.put("mchId", platMer.getMerKey());
         map.put("appId", platMer.getPublicKey());
         map.put("productId", platMerBaseCode.getBaseCode());
         map.put("mchOrderNo", platMerOrderParam.getOrderId());
         map.put("currency", "cny");
         map.put("clientIp", platMerOrderParam.getClientIp().split(",")[0].trim());
         map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
         map.put("notifyUrl", channel.getNotifyUrl());
         map.put("subject", "test");
         map.put("body", "test");
         map.put("extra", "");

         String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
         String sign = SecureUtil.md5(s).toUpperCase();
         log.info("dingPay launch s " + s);
         log.info("dingPay launch md5(s) " + sign);
      
         map.put("sign", sign);
//         map.put(Epay.REAL_URL, channel.getRealUrl());
         log.info("dingPay launch map " + map);

         String body = HttpUtil.createPost(channel.getRealUrl()).form(map).execute().body();
         log.info("dingPay launch body {}", body);
         return new PayUrl(2, channel.getChannelCode(), body, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }
    
    public PayUrl siruiPayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());
        if (channel.getChannelCode().equals("wenxinpay")) {
            sortedMap.put("pay_is_form", "1");
        }
        String s = convertUrl(sortedMap, "&", "=");
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        s = s + "&pay_productname=test&pay_md5sign=" + sign;
        String createUrl = channel.getCreateUrl();

        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }
    
    
    public PayUrl huangjiaPayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getNotifyUrl());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("pay_amount", decimalFormat.format(platMerOrderParam.getAmount()));
        
        String s = convertUrl(sortedMap, "&", "=");
        log.warn("sortedMap data {}",s + "&key=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&key="  + platMer.getPrivateKey()).toUpperCase();
        sortedMap.put("pay_type", "1");
        s = convertUrl(sortedMap, "&", "=") + "&sign=" + sign;
        String createUrl = channel.getCreateUrl();
        log.warn("debug url {}"+channel.getChannelCode(), createUrl + "?" + s);
        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    public PayUrl dongfangPayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        SortedMap sortedMap = new TreeMap();
        sortedMap.put("pay_memberid", platMer.getMerKey());
        sortedMap.put("pay_orderid", platMerOrderParam.getOrderId());
        sortedMap.put("pay_applydate", DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        sortedMap.put("pay_bankcode", platMerBaseCode.getBaseCode());
        sortedMap.put("pay_notifyurl", channel.getNotifyUrl());
        sortedMap.put("pay_callbackurl", channel.getSuccessUrl());
        sortedMap.put("pay_amount", platMerOrderParam.getAmount().toString());

        String s = convertUrl(sortedMap, "&", "=");
        log.warn("sortedMap data {}",s );
        
        
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toUpperCase();

        s = s + "&format=&pay_productname=test&pay_md5sign=" + sign;
        String createUrl = channel.getCreateUrl();

        return new PayUrl(1, channel.getChannelCode(), createUrl + "?" + s, platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
    }

    
    
    public PayUrl guchengUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
    Map sortedMap = new TreeMap();
	   sortedMap.put("mch_id", platMer.getMerKey());
	    sortedMap.put("child_type", platMerBaseCode.getBaseCode());
	    sortedMap.put("out_trade_no", platMerOrderParam.getOrderId());
	    sortedMap.put("mch_secret", platMer.getPrivateKey());
	    sortedMap.put("pay_type", "PERSONAL_RED_PACK");
	    sortedMap.put("total_fee", String.format("%.2f", platMerOrderParam.getAmount()));
	    try {
	        sortedMap.put("notify_url", URLEncoder.encode(channel.getNotifyUrl(), "utf-8"));
	    } catch (Exception ex) {
	        log.error(" url encode error {}", channel.getNotifyUrl(), ex);
	    }
	    sortedMap.put("timestamp", (System.currentTimeMillis() / 1000) + "");

	    String s = convertUrl(sortedMap, "&", "=");

	    String sign = SecureUtil.md5(s).toUpperCase();
	    String createUrl = channel.getCreateUrl();

	    log.info("orderId {}", platMerOrderParam.getOrderId());

	    sortedMap.remove("mch_secret");
	    String body = HttpUtil.createGet(createUrl + "?" + convertUrl(sortedMap, "&", "=") + "&" + Epay.REAL_URL + "=" + channel.getRealUrl() + "&sign=" + sign).execute().body();
	    JSONObject jsonObject = JSONObject.parseObject(body);
	    log.info("result a qiang {}", jsonObject.toJSONString());

	    if (jsonObject.getBoolean("status") == true && jsonObject.getInteger("code").intValue() == 100) {

	        return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

	    }
	    return null;
    }
    public PayUrl dongPayUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", platMer.getPublicKey());
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
//        map.put("extra", "{\"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
            log.info("jinxin launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("codeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.info("jinxin launch return null");
        return null;
    }

    public PayUrl yundingNewUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("merchantNum", platMer.getMerKey());
        sortedMap.put("orderNo", platMerOrderParam.getOrderId());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        sortedMap.put("out_trade_no", platMerOrderParam.getOrderId());
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("payType", platMerBaseCode.getBaseCode());

        String signUrl = platMer.getMerKey() + platMerOrderParam.getOrderId() + decimalFormat.format(platMerOrderParam.getAmount()) + channel.getNotifyUrl() + platMer.getPrivateKey();
        sortedMap.put("sign", SecureUtil.md5(signUrl).toLowerCase());

        sortedMap.put("returnUrl", "http://www.baidu.com");
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("yi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("yi launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("yi launch error");
        return null;
    }
    public PayUrl wanyunUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("mchId", platMer.getMerKey());
        map.put("amount", platMerOrderParam.getAmount());
        map.put("bankCode",platMerBaseCode.getBaseCode());
        map.put("clientIp",  platMerOrderParam.getClientIp().split(",")[0].trim());
        map.put("goodsName","test");
        
        map.put("notiryUrl", channel.getNotifyUrl());
        map.put("orderNo", platMerOrderParam.getOrderId());
        map.put("payTime", DateUtil.format(new Date(), "yyyyMMddHHmmss"));
        map.put("returnUrl", channel.getNotifyUrl());
        
        String s = convertUrlNotEmpty(map, "&", "=")  + platMer.getPrivateKey();
        log.error("s wanyun {}",s);
        String sign = SecureUtil.md5(s).toLowerCase();
        map.put("sign", sign);
        
        String body = HttpRequest.post(channel.getRealUrl()).header("Content-Type", "application/json").body(JSONObject.toJSONString(map)).execute().body();

        //RState
        
        log.info("yi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("1").equals(jsonObject.getString("RState"))) {
            log.info("yi launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("Data"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }
        return null;

    }
    public PayUrl damiNewUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap<>();
        map.put("mch_id", platMer.getMerKey());
        map.put("ordersn", platMerOrderParam.getOrderId());
        map.put("amount", platMerOrderParam.getAmount());
        map.put("typecode",platMerBaseCode.getBaseCode());
        map.put("callbackurl", channel.getNotifyUrl());
        map.put("is_form", "2");
        map.put("notifyurl", channel.getNotifyUrl());
        map.put("ordersn", platMerOrderParam.getOrderId());
        map.put("date", DateUtil.format(new Date(), "yyyy-MM-dd HH-mm-ss"));
        
        String s = convertUrlNotEmpty(map, "&", "=")+"&key="  + platMer.getPrivateKey();
        log.error("s damiNew {}",s);
        String sign = SecureUtil.md5(s).toUpperCase();
        map.put("sign", sign);
        
        String body = HttpRequest.post(channel.getRealUrl()).form((map)).execute().body();

        //RState
        
        log.info("yi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
//        if (("1").equals(jsonObject.getString("RState"))) {
//            log.info("yi launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("pay_url"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
//        }
//        return null;

    }
    
    public PayUrl daxiangUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("merchantNum", platMer.getMerKey());
        sortedMap.put("orderNo", platMerOrderParam.getOrderId());
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("amount", decimalFormat.format(platMerOrderParam.getAmount()));
        sortedMap.put("out_trade_no", platMerOrderParam.getOrderId());
        sortedMap.put("notifyUrl", channel.getNotifyUrl());
        sortedMap.put("payType", platMerBaseCode.getBaseCode());

        String signUrl = platMer.getMerKey() + platMerOrderParam.getOrderId() + decimalFormat.format(platMerOrderParam.getAmount()) + channel.getNotifyUrl() + platMer.getPrivateKey();
        sortedMap.put("sign", SecureUtil.md5(signUrl).toLowerCase());

        sortedMap.put("returnUrl", "http://www.baidu.com");
        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        log.info("yi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        if (("200").equals(jsonObject.getString("code"))) {
            log.info("yi launch success");
            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("data").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
        }

        log.error("yi launch error");
        return null;
    }
    public PayUrl tianyuNewUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> map = new TreeMap();
        map.put("mchId", platMer.getMerKey());
        map.put("appId", "6f26909e337b4ce0823b4f8c4ff11c87");
        map.put("productId", platMerBaseCode.getBaseCode());
        map.put("mchOrderNo", platMerOrderParam.getOrderId());
        map.put("currency", "cny");
        map.put("amount", (platMerOrderParam.getAmount().multiply(new BigDecimal(100))));
        map.put("notifyUrl", channel.getNotifyUrl());
        map.put("subject", "test");
        map.put("body", "test");
        map.put("extra", "{\"openId\":\"o2RvowBf7sOVJf8kJksUEMceaDqo\"}");

        String s = convertUrlNotEmpty(map, "&", "=") + "&key=" + platMer.getPrivateKey();
        String sign = SecureUtil.md5(s).toUpperCase();
        log.info("jinxin launch s " + s);
        log.info("jinxin launch md5(s) " + sign);

        map.put("sign", sign);
        map.put(Epay.REAL_URL, channel.getRealUrl());
        log.info("jinxin launch map " + map);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(map).execute().body();
        log.info("jinxin launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
//        if (("SUCCESS").equals(jsonObject.getString("retCode"))) {
//            log.info("jinxin launch success");
//            return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("codeUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());
//        }
        
        return new PayUrl(1, channel.getChannelCode(), jsonObject.getJSONObject("payParams").getString("payUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

//        log.info("jinxin launch return null");
//        return null;
    }
    public PayUrl duijieiosUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("MchNo", platMer.getMerKey());
        sortedMap.put("MchNbr", platMerOrderParam.getOrderId());
        
        sortedMap.put("Name", "iphone");
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        sortedMap.put("Amt", decimalFormat.format(platMerOrderParam.getAmount()));
        sortedMap.put("PayShowUrl", channel.getNotifyUrl());
        sortedMap.put("NotifyUrl", channel.getNotifyUrl());
        sortedMap.put("CreateTime",DateUtil.format(platMerOrderParam.getCreatedAt(), "yyyyMMddHHmmss"));
        sortedMap.put("CreateIp",  platMerOrderParam.getClientIp().split(",")[0].trim());
        String s = convertUrlNotEmpty(sortedMap, "&", "=") + platMer.getPrivateKey();
        log.info("duijieiosUrl launch s " + s);
        
        sortedMap.put("sign", SecureUtil.md5(s).toLowerCase());

        
        
        String body = HttpUtil.createPost(channel.getRealUrl()).header("Content-Type", "application/json").body(JSONObject.toJSONString(sortedMap)).execute().body();
        log.info("yi launch body {}", body);
        JSONObject jsonObject = JSONObject.parseObject(body);
        return new PayUrl(1, channel.getChannelCode(), jsonObject.getString("PayUrl"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

    }
    public PayUrl dayeUrl(PlatMer platMer, PlatMerBaseCode platMerBaseCode, PlatMerOrderParam platMerOrderParam, MerChannel channel) {
        Map<String, Object> sortedMap = new TreeMap<>();
        sortedMap.put("mch_id", platMer.getMerKey());
        sortedMap.put("ptype", platMerBaseCode.getBaseCode());
        sortedMap.put("order_sn", platMerOrderParam.getOrderId());
        sortedMap.put("money", String.format("%.2f", platMerOrderParam.getAmount()));
        sortedMap.put("goods_desc", "good");
        sortedMap.put("client_ip", "127.0.0.1");
        sortedMap.put("format", "json");
        sortedMap.put("notify_url", channel.getNotifyUrl());
        sortedMap.put("time", (System.currentTimeMillis() / 1000) + "");


        String s = convertUrlIsEmptyObject(sortedMap, "&", "=");


        log.info("recharge url {}", s);
        log.info("recharge url  md5 data {}", s + "&key=" + platMer.getPrivateKey());
        String sign = SecureUtil.md5(s + "&key=" + platMer.getPrivateKey()).toLowerCase();

        sortedMap.put(Epay.REAL_URL, channel.getRealUrl());
        sortedMap.put("sign", sign);

        String body = HttpUtil.createPost(channel.getCreateUrl()).form(sortedMap).execute().body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("result a taobaourl {}", body);
        if (jsonObject.getInteger("code").intValue() == 1) {


            return new PayUrl(1, channel.getChannelCode(), channel.getRealUrl() + "&a=info&osn=" + jsonObject.getJSONObject("data").getString("order_sn"), platMerOrderParam.getOrderId(), true, platMerOrderParam.getAmount());

        }

        return null;
    }
}
